What is EAV model in Magento?

EAV stands for Entity Attribute Value Model.

EAV also known as object attribute value model and open schema.

Entity (E): Entity actually refers to data item. For example we can consider it as customer, category or product.

Attribute (A): Attribute refers to the different attributes of the Entity. Like for example product have different attributes like color, size, price, etc.

Value (V): Value refers to the actual value of the attribute of the entity. Like color has value red, price has value $25, etc.

Below is the basic structure of the EAV (Considering product as an example):

Entity:

product_id

Attribute:

attribute_id

product_id

attribute_name

Value:

attribute_id

product_id

attribute_value

Sample data are as below:

Entity:

product_id (1)

Attribute:

attribute_id (1)                                                attribute_id (2)

product_id (1)                                                  product_id (1)

attribute_name (color)                                  attribute_name (price)

Value:

attribute_id (1)                                                     attribute_id (2)

product_id (1)                                                       product_id (1)

attribute_value (red)                                           attribute_value (290)

As per the above table structure, magento stores entry in three tables (actually more than three, but for this point it’s three). When you enter product in magento you have to insert different attributes of the product. So when you insert one product it will make one main entry in entity table. Then after with the reference of that entity id it will insert the various attributes (only name) of entity. At last with reference of entity id and attribute ids it will insert the actual value of the different attributes.

This is the basic structure of EAV which magento use. There may be (actually there are) some more complex structure of the EAV available but the main concept will remain same.

Why to use EAV?

EAV used because of scalability. We can insert anything without changing its structure. This is the main benefit of this structure.

Main problem with EAV structure is that, it is much slower than custom made solution because of SQL query complexity.

You need to make few join to retrieve just a single entity and in opposite in custom made solution we just have to make one simple select query to retrieve single entity.

Magento uses EAV structure because its designed to be scalable, regardless of speed problem.

About the Author: Avinash

Experienced full stack freelance web developer with a track record of producing excellent results for 11+ years. Excellent communication and collaboration skills, managing with a team of 20+ people. I’m motivated to make a positive impact on your revenue through the customer web portal development project.

11 Comments

  1. […] This post was mentioned on Twitter by Avinash Zala, Avi. Avi said: What is EAV model in Magento?: EAV stands for Entity Attribute Value Model. EAV also known as object attribute val… http://bit.ly/d3YjmE […]

  2. […] because of the EAV database structure. To more about the EAV database structure see my post on EAV database structure in Magento. But EAV database model is not much faster in terms of the performance. This is because we need […]

  3. Ferry Ardhana August 21, 2011 at 1:20 am - Reply

    Yeah.. Magento have very high scalability. And because of that have problem on loading process.
    Maybe there is one of reason why is recomended to enable catalog flat table and always keep index is up to date on magento backend.
    Because when index process is running, they are collecting summary data from entity into only one table (catalog_product_flat_). CMIIW. :)

    • Avinash August 21, 2011 at 2:05 am - Reply

      Hi Ferry,

      Thanks for sharing this information.

  4. kiran November 11, 2011 at 6:55 pm - Reply

    Very nice and useful article. Thank you very much

  5. Iqbal April 10, 2012 at 6:36 pm - Reply

    I am new to magento and found that good understanding of EAV model of magento is a key to good grasp on magento.

  6. Bokin April 24, 2012 at 7:28 pm - Reply

    In your article, I realized that why the magento was slow. Thanks :)

  7. […] Article on Magento after very long time. Last article which I have posted about magento is about Magento EAV Database structure. In that article I have explained the reason for the flexibility […]

  8. Anusha E September 20, 2014 at 6:11 pm - Reply

    thanks ,the information is very helpful :)

  9. Asraful Haque December 30, 2014 at 12:23 am - Reply

    Thanks this is very useful content.

  10. Banvari Lal January 14, 2018 at 11:46 pm - Reply

    very good explaination

Leave A Comment

FREE QUOTE

Do you need help with services? Request a free quote to get in touch.