Tuesday, February 4, 2014

Magento 1.1 EAV-Database model

Entity–attribute–value model

Entity–attribute–value model (EAV) is a data model to describe entities where the number of attributes (properties, parameters) that can be used to describe them is potentially vast.
 In mathematics, this model is known as asparse matrix.

EAV is also known as object–attribute–value model,vertical database model and open schema.
Many cases where data can be modelled in statically relational terms an EAV based approach is an anti-pattern which can lead to longer development times.

we have a user entity which has attribute firstname,lastname,address then in traditional table structure we would create a table with name ‘user’ and add columns to the table named firstname,lastname,address. Maybe a few more columns like Primary Key or Foreign Key depending on our business requirements.

entity in which the number of attribute/columns is very large lets say 100 and on top of that only few attributes are required i.e when we gather data about that entity out of the 100 columns around 10% of the columns we get data, rest 90% we rarely get data. In such a case our traditional table would have a single table with 100 columns and most the columns would be empty or filled with NULL values. This would be a very bad table structure for such a data. In such case, we use EAV database model for tables.

No comments:

Post a Comment