EAV data model
Presenter: Sandeep Kumar Rout, Mindfire Solutions
Date: 20/03/2014
1/2/12
Presenter: Sandeep Kumar Rout, Mindfire
Solutions
Date: 20/03/2014
About Me
M70 101 – Magento Certified Developer
Skills: PHP, Magento, SugarCRM,
CakePHP, oSCommerce, CodeIgniter
Connect Me: -
Twitter : https://twitter.com/saaandh090
Facebook : https://www.facebook.com/sandeep.rout.359
LinkedIn : http://www.linkedin.com/pub/sandeep-rout/39
Google+ : https://plus.google.com/112206647165680165211/
Contact Me:
Email: sandeepr@mindfiresolutions.com
Skype: mfsi_sandeepr
1/2/12
Agenda

Introduction

History

EAV hierarchy structure

Data Retrieve

EAV when to use?

Attribute Set

Pros

Cons Presenter: Sandeep Kumar Rout, Mindfire
Solutions
Date: 20/03/2014
1/2/12
EAV
Entity Attribute Value (EAV) is vertical data
modeling instead of horizontal data modeling
which we regularly use.
In mathematics, this model is known as a
sparse matrix.
EAV is also known as object–attribute–value
model, vertical database model and open
schema.
Presenter: Sandeep Kumar Rout, Mindfire
Solutions
Date: 20/03/2014
1/2/12
EAV History
As a storage method EAV was used in early
object-oriented languages like SIMULA 67.
Functional languages such as LISP have also
use EAV data structure. They contain storage
structures that record object information in
attribute-value pairs – a principle
fundamental to EAV.
Presenter: Sandeep Kumar Rout, Mindfire
Solutions
Date: 20/03/2014
1/2/12
EAV hierarchy structure
EAV hierarchy structure includes these
components:
- Entity : A component with a definitive
existence. Objects are entities. For e.g.
Products, User etc
- Attribute : The fields to which the entities
are related. This are similar to column names
in horizontal data models. Object properties
are attributes
i.e. :- Color, Name, Price etc
Presenter: Sandeep Kumar Rout, Mindfire
Solutions
Date: 20/03/2014
1/2/12
- Value : The value to which entity and
attribute maps to. They are similar to row
value from horizontal database.
Example :- John, $22, blue etc
Presenter: Sandeep Kumar Rout, Mindfire
Solutions
Date: 20/03/2014
1/2/12
Presenter: Sandeep Kumar Rout, Mindfire
Solutions
Date: 20/03/2014
1/2/12
Data Retrieve
Case :-
To get phone no of employee whose id is 1
Basic model :
SELECT phone_no FROM employee WHERE
employee_id = 1;
Presenter: Sandeep Kumar Rout, Mindfire
Solutions
Date: 20/03/2014
1/2/12
Presenter: Sandeep Kumar Rout, Mindfire
Solutions
Date: 20/03/2014
Eav model :
SELECT value FROM employee_int as ei
JOIN employee as e
ON e.employee_id = ei.employee_id
JOIN employee_attribute as ea
ON ea.attribute_id = ei.attribute_id
WHERE e.employee_id = 1 AND
ea.attribute_name = 'phone_no'
1/2/12
EAV when to use?
Presenter: Sandeep Kumar Rout, Mindfire
Solutions
Date: 20/03/2014
Consider a case where there is need to add
new columns or remove new columns on a
regular basis. If using a simple single table it
needs frequent alteration of tables also causes
complexities
With EAV this can be done by simple addition
of a new row in attributes table.
So, generally eav is used in such cases.
1/2/12
Attribute Set
Set of attributes combined to make the entity grouped with
their respective attributes only.
Example :- An online store having books and shirts.
Attributes used by book are different from attributes
used by shirt. So, they can be categorized into attributes
set.
Attribute set Shirt : size, color, price,material, manufacturer
etc
Attribute set Book : pages, author, type of binding,etc
Presenter: Sandeep Kumar Rout, Mindfire
Solutions
Date: 20/03/2014
1/2/12
Pros

Flexible mechanism for attributes to work
with any sort of entities

Scalability – Can change the required data
without changing the structure of database
tables

Independent of hierarchy of data. Less time
to implement Presenter: Sandeep Kumar Rout, Mindfire
Solutions
Date: 20/03/2014
1/2/12
Cons

Performance

EAV don't store value as datatype specific.
Similar type of data are all grouped in one.
As int is generally used to store tinyint,int
etc.

No grouping of entities
Presenter: Sandeep Kumar Rout, Mindfire
Solutions
Date: 20/03/2014
1/2/12
Indexing
This process is used to somehow compensate
the poor performance of EAV structure. It is
not similar to database indexing

This process is time consuming

In this process data from EAV structured
tables are retrieved and store in flat tables

Initially done after all entity types are
generated
Presenter: Sandeep Kumar Rout, Mindfire
Solutions
Date: 20/03/2014
1/2/12

Need to perform this process regularly

Need to be performed on addition, updation
and deletion of data

Makes the data retrieval easier and faster

It completely eliminates old table and
generates new table when re-indexing is
performed.
Presenter: Sandeep Kumar Rout, Mindfire
Solutions
Date: 20/03/2014
Question and Answer
Presenter: Sandeep Kumar Rout, Mindfire
Solutions
Date: 20/03/2014
Thank you
Presenter: Sandeep Kumar Rout, Mindfire
Solutions
Date: 20/03/2014
www.mindfiresolutions.com
https://www.facebook.com/MindfireSolutions
http://www.linkedin.com/company/mindfire-solutions
http://twitter.com/mindfires

Eav Data Model Concepts

  • 1.
    EAV data model Presenter:Sandeep Kumar Rout, Mindfire Solutions Date: 20/03/2014
  • 2.
    1/2/12 Presenter: Sandeep KumarRout, Mindfire Solutions Date: 20/03/2014 About Me M70 101 – Magento Certified Developer Skills: PHP, Magento, SugarCRM, CakePHP, oSCommerce, CodeIgniter Connect Me: - Twitter : https://twitter.com/saaandh090 Facebook : https://www.facebook.com/sandeep.rout.359 LinkedIn : http://www.linkedin.com/pub/sandeep-rout/39 Google+ : https://plus.google.com/112206647165680165211/ Contact Me: Email: sandeepr@mindfiresolutions.com Skype: mfsi_sandeepr
  • 3.
    1/2/12 Agenda  Introduction  History  EAV hierarchy structure  DataRetrieve  EAV when to use?  Attribute Set  Pros  Cons Presenter: Sandeep Kumar Rout, Mindfire Solutions Date: 20/03/2014
  • 4.
    1/2/12 EAV Entity Attribute Value(EAV) is vertical data modeling instead of horizontal data modeling which we regularly use. In mathematics, this model is known as a sparse matrix. EAV is also known as object–attribute–value model, vertical database model and open schema. Presenter: Sandeep Kumar Rout, Mindfire Solutions Date: 20/03/2014
  • 5.
    1/2/12 EAV History As astorage method EAV was used in early object-oriented languages like SIMULA 67. Functional languages such as LISP have also use EAV data structure. They contain storage structures that record object information in attribute-value pairs – a principle fundamental to EAV. Presenter: Sandeep Kumar Rout, Mindfire Solutions Date: 20/03/2014
  • 6.
    1/2/12 EAV hierarchy structure EAVhierarchy structure includes these components: - Entity : A component with a definitive existence. Objects are entities. For e.g. Products, User etc - Attribute : The fields to which the entities are related. This are similar to column names in horizontal data models. Object properties are attributes i.e. :- Color, Name, Price etc Presenter: Sandeep Kumar Rout, Mindfire Solutions Date: 20/03/2014
  • 7.
    1/2/12 - Value :The value to which entity and attribute maps to. They are similar to row value from horizontal database. Example :- John, $22, blue etc Presenter: Sandeep Kumar Rout, Mindfire Solutions Date: 20/03/2014
  • 8.
    1/2/12 Presenter: Sandeep KumarRout, Mindfire Solutions Date: 20/03/2014
  • 9.
    1/2/12 Data Retrieve Case :- Toget phone no of employee whose id is 1 Basic model : SELECT phone_no FROM employee WHERE employee_id = 1; Presenter: Sandeep Kumar Rout, Mindfire Solutions Date: 20/03/2014
  • 10.
    1/2/12 Presenter: Sandeep KumarRout, Mindfire Solutions Date: 20/03/2014 Eav model : SELECT value FROM employee_int as ei JOIN employee as e ON e.employee_id = ei.employee_id JOIN employee_attribute as ea ON ea.attribute_id = ei.attribute_id WHERE e.employee_id = 1 AND ea.attribute_name = 'phone_no'
  • 11.
    1/2/12 EAV when touse? Presenter: Sandeep Kumar Rout, Mindfire Solutions Date: 20/03/2014 Consider a case where there is need to add new columns or remove new columns on a regular basis. If using a simple single table it needs frequent alteration of tables also causes complexities With EAV this can be done by simple addition of a new row in attributes table. So, generally eav is used in such cases.
  • 12.
    1/2/12 Attribute Set Set ofattributes combined to make the entity grouped with their respective attributes only. Example :- An online store having books and shirts. Attributes used by book are different from attributes used by shirt. So, they can be categorized into attributes set. Attribute set Shirt : size, color, price,material, manufacturer etc Attribute set Book : pages, author, type of binding,etc Presenter: Sandeep Kumar Rout, Mindfire Solutions Date: 20/03/2014
  • 13.
    1/2/12 Pros  Flexible mechanism forattributes to work with any sort of entities  Scalability – Can change the required data without changing the structure of database tables  Independent of hierarchy of data. Less time to implement Presenter: Sandeep Kumar Rout, Mindfire Solutions Date: 20/03/2014
  • 14.
    1/2/12 Cons  Performance  EAV don't storevalue as datatype specific. Similar type of data are all grouped in one. As int is generally used to store tinyint,int etc.  No grouping of entities Presenter: Sandeep Kumar Rout, Mindfire Solutions Date: 20/03/2014
  • 15.
    1/2/12 Indexing This process isused to somehow compensate the poor performance of EAV structure. It is not similar to database indexing  This process is time consuming  In this process data from EAV structured tables are retrieved and store in flat tables  Initially done after all entity types are generated Presenter: Sandeep Kumar Rout, Mindfire Solutions Date: 20/03/2014
  • 16.
    1/2/12  Need to performthis process regularly  Need to be performed on addition, updation and deletion of data  Makes the data retrieval easier and faster  It completely eliminates old table and generates new table when re-indexing is performed. Presenter: Sandeep Kumar Rout, Mindfire Solutions Date: 20/03/2014
  • 17.
    Question and Answer Presenter:Sandeep Kumar Rout, Mindfire Solutions Date: 20/03/2014
  • 18.
    Thank you Presenter: SandeepKumar Rout, Mindfire Solutions Date: 20/03/2014
  • 19.