It is well known that Magento implements an entity-attribute-value data model. A key table in the implementation is the ‘eav_attribute’ table, who’s exposition is the subject of this blog post.
Magento uses five ‘types’ to store attribute data: datetime, decimal, int, text, and varchar (these are strongly motivated by the corresponding mySQL datatypes). So when a new eav entity type is created in Magento there are actually six tables created; one to store the entity and one for each of these ‘types’ of attribute data. The fact that this type of entity has a certain attribute is recorded in the ‘eav_attribute’ table which has the following schema:
‘attribute_id’ is simply a primary key for this table.
‘entity_type_id’ is a reference to the ‘eav_entity_type’ table and tells Magento what entity has the attribute in this record. Typical examples are ‘customer’ and ‘catalog_product’.
‘attribute_code’ is a developer-readable name we can use to retrieve the attribute. A typical use would be $eavModel->getResource()->getAttribute('my_attribute');. Note that the UNIQUE KEY statement in the schema guarantees that these codes will be unique for each entity.
‘backend_model’ is to do with how the entity is saved into the database; this class will extend Mage_Eav_Model_Entity_Attribute_Backend_Abstract.
‘backend_type’ is simply one of the five Magento eav datatypes (datetime, decimal, int, text, or varchar), or the value ‘static’ which means this attribute is stored in the parent entity table as opposed to one of the five auxillary tables.
‘frontend_model’ is a model class for use in displaying the attribute on the front end. For example product images are stored as ‘varchar’ attributes of the ‘catalog_product’ entity and their ‘frontend_model’ exposes a ‘getUrl’ method. The ‘frontend_model’ will extend Mage_Eav_Model_Entity_Attribute_Frontend_Abstract.
‘frontend_input’ describes the form element used to enter the attribute data in the admin section. This is related to the ‘backend_model’ field. If there’s nothing in the ‘backend_model’ field then I think this needs to identify one of the classes in the Mage_Eav_Model_Attribute_Data folder.
‘frontend_label’ is simply a human-readable label to help the administrator enter the attribute data in the back end.
‘frontend_class’ is a CSS class for the admin form.
‘source_model’ will extend Mage_Eav_Model_Entity_Attribute_Source_Abstract, or at the very least implement Mage_Eav_Model_Entity_Attribute_Source_Interface, in which “Source is providing the selection options for user interface”.
The rest are pretty self-explanatory: