All Magento Models inherit from the Mage_Core_Model_Abstract.Magento splits the model layer up into two parts as you’ve recognised, with the Model handling the business-logic, and the Resource part only dealing with talking to the database .The Resource also has two different types one is Entity and other is Mysql4. We will discuss differences between Models, Resource models and Collections in Magento later on.
To build a model with proper collection object in Magento you need 4 things:
1 – model class
2 – resource class
3 – collection class
4 – install script( Mysql4)
Basic concepts of models, resource models, and collections are follwoing:
Magento Models is handle all logical operation with database.Its ActiveRecord-like/one-object-one-table Model, and there’s also an Entity Attribute Value (EAV) Model. Each Model also gets a Model Collection. .
Magento’s resource simply connect with the database and performs the CRUD operations. Actually they manage the different reading/writing connections.Its another layer beetween model and database when you intracting with database.
Collection referes the collection of models.it contains many models.When we want results based on diffrent model then we need to create collection or we can use existing collection.
It gives us a whole load of convenience methods, making it easier to manipulate lists of entities and reducing the need to write complex sql.