Magento EAV (Entity Attribute Value) data model is used to get flexibility for your data, but it brings more complexity than relation table model. If you need a data model that will have flexible attributes which can be dynamically added, for example from Magento admin panel, then EAV is the best solution for you. If using EAV, you don’t need to change table structure for every new attribute like you do on flat tables (creating new columns).
EAV is also known as Object–Attribute–Value model, vertical database model, and open schema. EAV is Entity-Attribute-Value is the vertical modeling technique of columns in the database. Instead of a table consisting of a number of columns, denoting attributes of a conceptual piece of data, the attributes are stored in one column of a separate table.
What is Entity?
An entity is an object that exists. In a database, an entity can be a single thing, person, place, or object. Data can be stored about such entities.For example: In Magento entities are product, customer, order etc.
What is an attribute?
An attribute defines the information about the entity that needs to be stored. If the entity is an employee, attributes could include name, employee ID, health plan enrollment, and work location. An entity will have zero or more attributes, and each of those attributes applies only to that entity. For example, the employee ID of 123456 belongs to that employee entity alone.
What is a value?
The value is nothing but the value of an attribute. For example employee id 12345, here ‘123456’ is the value of the attribute employee id.
- EAV is a flexible mechanism.
- It requires very little time for implementation.
- Its model doesn’t change when the model changes.
- The database schema doesn’t change when the model changes.
- The EAV does not provide a mechanism to create relationship between
- entities of different sub-types.
- The EAV uses varchar column for all attribute values regardless of dates,
- timestamp, integer etc.