Movatterモバイル変換


[0]ホーム

URL:


Uploaded byTâm
PPT, PDF13,871 views

Entity Attribute Value (Eav)

The document discusses the entity-attribute-value (EAV) data model used in Magento, where attributes are stored in a separate table rather than columns. EAV provides flexibility but can result in inefficient queries; solutions include using a pivot table or Amazon SimpleDB which avoids complex queries and requires no database administration.

Embed presentation

Downloaded 296 times
Entity - Attribute - Value (EAV) Data Model in Magento  @Pờ Đình Tâm
What is EAV EAV can be thought of as “vertical” modeling instead of “horizontal” modeling of columns in a database table. 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.
Traditional User Table table: user_entity
EAV Style Tables
Structure of an EAV table The entity: Objects are entities (in Magento. Entities are: product, customer, order,…) The attribute: object properties are attributes The value: The value of the attribute
Update SQL: UPDATE `eav_attribute` SET `attribute_id` = ?, `entity_type_id` = ?, `attribute_code` = ?, `attribute_model` = ?, `backend_model` = ?, `backend_type` = ?, `backend_table` = ?, `frontend_model` = ?, `frontend_input` = ?, `frontend_input_renderer` = ?, `frontend_label` = ?, `frontend_class` = ?, `source_model` = ?, `is_global` = ?, `is_visible` = ?, `is_required` = ?, `is_user_defined` = ?, `default_value` = ?, `is_searchable` = ?, `is_filterable` = ?, `is_comparable` = ?, `is_visible_on_front` = ?, `is_html_allowed_on_front` = ?, `is_unique` = ?, `is_used_for_price_rules` = ?, `is_filterable_in_search` = ?, `used_in_product_listing` = ?, `used_for_sort_by` = ?, `is_configurable` = ?, `apply_to` = ?, `position` = ?, `note` = ?, `is_visible_in_advanced_search` = ? WHERE (attribute_id='498') BIND: Array ( [0] => 498 [1] => 4 [2] => sp_test [3] =>  [4] =>  [5] => varchar [6] =>  [7] =>  [8] => text [9] =>  [10] => sp test [11] =>  [12] =>  [13] => 0 [14] => 1 [15] => 0 [16] => 1 [17] =>  [18] => 1 [19] => 0 [20] => 1 [21] => 0 [22] => 1 [23] => 0 [24] => 0 [25] => 0 [26] => 0 [27] => 0 [28] => 0 [29] =>  [30] => 0 [31] =>  [32] => 1 )
Delete SQL: DELETE FROM `eav_attribute` WHERE (attribute_id='498')
Read SQL:  SELECT COUNT(DISTINCT e.entity_id)  FROM `catalog_product_entity` AS `e` INNER JOIN `catalog_category_product_index` AS `cat_index`  ON cat_index.product_id=e.entity_id  AND cat_index.store_id='1'  AND cat_index.visibility  IN(3, 4)  AND cat_index.category_id='2'  WHERE    (   e.entity_id in    (   SELECT `t1`.`entity_id` FROM `catalog_product_entity_varchar` AS `t1`   LEFT JOIN `catalog_product_entity_varchar` AS `t2`    ON t1.entity_id = t2.entity_id    AND t1.attribute_id = t2.attribute_id    AND t2.store_id='1'    WHERE (t1.store_id = 0)    AND (t1.attribute_id = 498)    AND (IFNULL(t2.value, t1.value) LIKE :attribute_498)    AND    (   t1.entity_id IN   (   SELECT `t1`.`entity_id` FROM `catalog_product_entity_int` AS `t1`   LEFT JOIN `catalog_product_entity_int` AS `t2`    ON t1.entity_id = t2.entity_id    AND t1.attribute_id = t2.attribute_id    AND t2.store_id='1'    WHERE (t1.store_id = 0)    AND (t1.attribute_id = 497)    AND (IFNULL(t2.value, t1.value) IN ('0', '1'))    AND    (   t1.entity_id IN   (   SELECT `t1`.`entity_id`    FROM `catalog_product_entity_int` AS `t1`   LEFT JOIN `catalog_product_entity_int` AS `t2`    ON t1.entity_id = t2.entity_id AND t1.attribute_id = t2.attribute_id    AND t2.store_id='1'    WHERE (t1.store_id = 0) AND (t1.attribute_id = 496) AND (IFNULL(t2.value, t1.value) IN ('0', '1'))   )   )   )   )   )   ) BIND: Array ( [attribute_498] => %ten% )
Read(2)
Read(3) Relation database: SELECT *  FROM Employee  WHERE Name = ‘John’  AND Nationality = ‘English
Read(4) Self Join:  SELECT  t1.ID as 'ID' t1.Value AS ‘Name’,  t2.Value AS ‘Nationality’ t3.Value AS Birthday FROM EAV_Data t1 LEFT JOIN EAV_Data t2 ON t1.ID = t2.ID LEFT JOIN EAV_Data t3 ON t1.ID = t3.ID WHERE t1.Attribute = ‘Name’ AND t1.Value = ‘John’ AND t2.Attribute = ‘Nationality’ AND t2.Value = ‘English’ AND t3.Attribute = ‘Birthday
Good Provides a flexible mechanism to record the attributes associated with any entity. This EAV design requires almost no consideration of the nature of the applicable hierarchical data and requires very little time to implement  The database schema does not change when the model changes
Bad The EAV table doesn't provide a mechanism to create relationships between entities of different sub-types. The EAV table does nothing to provide a grouping of related entity types. The EAV table uses a VARCHAR column for all attribute values regardless if Dates, timestamps, integers, numerics or booleans would be more appropriate Inefficient queries. Where you would execute a simple query returning 20 columns from a single table, you end up with 20 self-joins, one for each column
Solution Take a look at Magento Database Diagram
EAV table with Pivot (3) Pivot SELECT * FROM ( SELECT ID , [100] AS Name , [101] AS Birthday , [102] AS Nationality FROM  ( SELECT ID, EntityID, AttributeID, Value FROM EAV_Table ) p PIVOT ( MAX (Value) FOR AttributeID IN ([100], [101], [102]) ) AS pvt ) WHERE Name = 'John' AND Nationality = 'English'
When Recommend from Amazon SimpleDB:  Principally utilize index and query functions rather than more complex relational database functions Don’t want any administrative burden at all in managing their structured data Want a service that scales automatically up or down in response to demand, without user intervention Require the highest availability and can’t tolerate downtime for data backup or software maintenance
Thanks for your attention

Recommended

PPTX
Sql server
PPTX
EAV Sytem- Magento EAV Model
PDF
4.3 MySQL + PHP
PPTX
MYSQL join
PPT
Sql Server Basics
PDF
SQL-Server Database.pdf
PPTX
Oracle database introduction
PDF
Trees and Hierarchies in SQL
PPTX
DATABASE CONSTRAINTS
PPT
Introduction to sql
PPTX
Overview SQL Server 2019
PPTX
Sql commands
PPTX
Advanced data access with Dapper
PPT
Introduction to data structure
PDF
MongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDB
PPTX
Database Modeling Using Entity.. Weak And Strong Entity Types
PPT
SQL : introduction
PPT
JavaScript Event Loop
PDF
stacks and queues
PDF
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
PDF
Database Anti Patterns
PDF
SQL Pattern Matching – should I start using it?
PPT
Introduction to-sql
PPTX
Sql Basics And Advanced
PPTX
Core Data Service
PDF
SQL Joins With Examples | Edureka
PPTX
ER model to Relational model mapping
PPT
EAV in Magento
 
PDF
Eav Data Model Concepts

More Related Content

PPTX
Sql server
PPTX
EAV Sytem- Magento EAV Model
PDF
4.3 MySQL + PHP
PPTX
MYSQL join
PPT
Sql Server Basics
PDF
SQL-Server Database.pdf
PPTX
Oracle database introduction
PDF
Trees and Hierarchies in SQL
Sql server
EAV Sytem- Magento EAV Model
4.3 MySQL + PHP
MYSQL join
Sql Server Basics
SQL-Server Database.pdf
Oracle database introduction
Trees and Hierarchies in SQL

What's hot

PPTX
DATABASE CONSTRAINTS
PPT
Introduction to sql
PPTX
Overview SQL Server 2019
PPTX
Sql commands
PPTX
Advanced data access with Dapper
PPT
Introduction to data structure
PDF
MongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDB
PPTX
Database Modeling Using Entity.. Weak And Strong Entity Types
PPT
SQL : introduction
PPT
JavaScript Event Loop
PDF
stacks and queues
PDF
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
PDF
Database Anti Patterns
PDF
SQL Pattern Matching – should I start using it?
PPT
Introduction to-sql
PPTX
Sql Basics And Advanced
PPTX
Core Data Service
PDF
SQL Joins With Examples | Edureka
PPTX
ER model to Relational model mapping
DATABASE CONSTRAINTS
Introduction to sql
Overview SQL Server 2019
Sql commands
Advanced data access with Dapper
Introduction to data structure
MongoDB World 2019: Tips and Tricks++ for Querying and Indexing MongoDB
Database Modeling Using Entity.. Weak And Strong Entity Types
SQL : introduction
JavaScript Event Loop
stacks and queues
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
Database Anti Patterns
SQL Pattern Matching – should I start using it?
Introduction to-sql
Sql Basics And Advanced
Core Data Service
SQL Joins With Examples | Edureka
ER model to Relational model mapping

Similar to Entity Attribute Value (Eav)

PPT
EAV in Magento
 
PDF
Eav Data Model Concepts
PDF
20. Magento Austria meetup - EAV Principles
KEY
MongoDB and Ecommerce : A perfect combination
PDF
Dare to build vertical design with relational data (Entity-Attribute-Value)
PDF
Database.pdf
PPTX
38. Magento Meetup Austria: Ivan Cuk - From Core to Custom. A Deep Dive into ...
PDF
Magento 2.1 ee content staging
DOCX
Database design guide
DOC
Create table dimcustomer ( customerid int/tutorialoutlet
DOCX
Running Head PROJECT DELIVERABLE 31PROJECT DELIVERABLE 310.docx
PDF
Inventory management system
DOCX
Inventory aging report using oracle discoverer desktop
PPTX
Subquery & view
PPT
Datawarehosuing
PPT
Data Warehousing
DOCX
Database Management Systems Project Report
PDF
Unit 2-Data Modeling.pdf
PPTX
Is 21 -_databases
PDF
Magento2dbschema1 180607144053
EAV in Magento
 
Eav Data Model Concepts
20. Magento Austria meetup - EAV Principles
MongoDB and Ecommerce : A perfect combination
Dare to build vertical design with relational data (Entity-Attribute-Value)
Database.pdf
38. Magento Meetup Austria: Ivan Cuk - From Core to Custom. A Deep Dive into ...
Magento 2.1 ee content staging
Database design guide
Create table dimcustomer ( customerid int/tutorialoutlet
Running Head PROJECT DELIVERABLE 31PROJECT DELIVERABLE 310.docx
Inventory management system
Inventory aging report using oracle discoverer desktop
Subquery & view
Datawarehosuing
Data Warehousing
Database Management Systems Project Report
Unit 2-Data Modeling.pdf
Is 21 -_databases
Magento2dbschema1 180607144053

Recently uploaded

PDF
Oracle MySQL HeatWave - Short - Version 3
PDF
[BDD 2025 - Mobile Development] Exploring Apple’s On-Device FoundationModels
PDF
So You Want to Work at Google | DevFest Seattle 2025
PDF
Top Crypto Supers 15th Report November 2025
PDF
Oracle MySQL HeatWave - Complete - Version 3
PDF
How Much Does It Cost to Build an eCommerce Website in 2025.pdf
PDF
[BDD 2025 - Full-Stack Development] Agentic AI Architecture: Redefining Syste...
PPTX
"Feelings versus facts: why metrics are more important than intuition", Igor ...
 
PDF
"DISC as GPS for team leaders: how to lead a team from storming to performing...
 
PPTX
The power of Slack and MuleSoft | Bangalore MuleSoft Meetup #60
PDF
Integrating AI with Meaningful Human Collaboration
PDF
[BDD 2025 - Mobile Development] Crafting Immersive UI with E2E and AGSL Shade...
PDF
Beyond Basics: How to Build Scalable, Intelligent Imagery Pipelines
PDF
Mastering Agentic Orchestration with UiPath Maestro | Hands on Workshop
PPTX
UFCD 0797 - SISTEMAS OPERATIVOS_Unidade Completa.pptx
PDF
Supervised Machine Learning Approaches for Log-Based Anomaly Detection: A Cas...
PDF
Oracle MySQL HeatWave - One Page - Version 3
PDF
The Necessity of Digital Forensics, the Digital Forensics Process & Laborator...
PDF
Mastering UiPath Maestro – Session 2 – Building a Live Use Case - Session 2
PDF
Mulesoft Meetup Online Portuguese: MCP e IA
Oracle MySQL HeatWave - Short - Version 3
[BDD 2025 - Mobile Development] Exploring Apple’s On-Device FoundationModels
So You Want to Work at Google | DevFest Seattle 2025
Top Crypto Supers 15th Report November 2025
Oracle MySQL HeatWave - Complete - Version 3
How Much Does It Cost to Build an eCommerce Website in 2025.pdf
[BDD 2025 - Full-Stack Development] Agentic AI Architecture: Redefining Syste...
"Feelings versus facts: why metrics are more important than intuition", Igor ...
 
"DISC as GPS for team leaders: how to lead a team from storming to performing...
 
The power of Slack and MuleSoft | Bangalore MuleSoft Meetup #60
Integrating AI with Meaningful Human Collaboration
[BDD 2025 - Mobile Development] Crafting Immersive UI with E2E and AGSL Shade...
Beyond Basics: How to Build Scalable, Intelligent Imagery Pipelines
Mastering Agentic Orchestration with UiPath Maestro | Hands on Workshop
UFCD 0797 - SISTEMAS OPERATIVOS_Unidade Completa.pptx
Supervised Machine Learning Approaches for Log-Based Anomaly Detection: A Cas...
Oracle MySQL HeatWave - One Page - Version 3
The Necessity of Digital Forensics, the Digital Forensics Process & Laborator...
Mastering UiPath Maestro – Session 2 – Building a Live Use Case - Session 2
Mulesoft Meetup Online Portuguese: MCP e IA

Entity Attribute Value (Eav)

  • 1.
    Entity - Attribute- Value (EAV) Data Model in Magento @Pờ Đình Tâm
  • 2.
    What is EAVEAV can be thought of as “vertical” modeling instead of “horizontal” modeling of columns in a database table. 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.
  • 3.
    Traditional User Tabletable: user_entity
  • 4.
  • 5.
    Structure of anEAV table The entity: Objects are entities (in Magento. Entities are: product, customer, order,…) The attribute: object properties are attributes The value: The value of the attribute
  • 6.
    Update SQL: UPDATE`eav_attribute` SET `attribute_id` = ?, `entity_type_id` = ?, `attribute_code` = ?, `attribute_model` = ?, `backend_model` = ?, `backend_type` = ?, `backend_table` = ?, `frontend_model` = ?, `frontend_input` = ?, `frontend_input_renderer` = ?, `frontend_label` = ?, `frontend_class` = ?, `source_model` = ?, `is_global` = ?, `is_visible` = ?, `is_required` = ?, `is_user_defined` = ?, `default_value` = ?, `is_searchable` = ?, `is_filterable` = ?, `is_comparable` = ?, `is_visible_on_front` = ?, `is_html_allowed_on_front` = ?, `is_unique` = ?, `is_used_for_price_rules` = ?, `is_filterable_in_search` = ?, `used_in_product_listing` = ?, `used_for_sort_by` = ?, `is_configurable` = ?, `apply_to` = ?, `position` = ?, `note` = ?, `is_visible_in_advanced_search` = ? WHERE (attribute_id='498') BIND: Array ( [0] => 498 [1] => 4 [2] => sp_test [3] => [4] => [5] => varchar [6] => [7] => [8] => text [9] => [10] => sp test [11] => [12] => [13] => 0 [14] => 1 [15] => 0 [16] => 1 [17] => [18] => 1 [19] => 0 [20] => 1 [21] => 0 [22] => 1 [23] => 0 [24] => 0 [25] => 0 [26] => 0 [27] => 0 [28] => 0 [29] => [30] => 0 [31] => [32] => 1 )
  • 7.
    Delete SQL: DELETEFROM `eav_attribute` WHERE (attribute_id='498')
  • 8.
    Read SQL:SELECT COUNT(DISTINCT e.entity_id) FROM `catalog_product_entity` AS `e` INNER JOIN `catalog_category_product_index` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id='1' AND cat_index.visibility IN(3, 4) AND cat_index.category_id='2' WHERE ( e.entity_id in ( SELECT `t1`.`entity_id` FROM `catalog_product_entity_varchar` AS `t1` LEFT JOIN `catalog_product_entity_varchar` AS `t2` ON t1.entity_id = t2.entity_id AND t1.attribute_id = t2.attribute_id AND t2.store_id='1' WHERE (t1.store_id = 0) AND (t1.attribute_id = 498) AND (IFNULL(t2.value, t1.value) LIKE :attribute_498) AND ( t1.entity_id IN ( SELECT `t1`.`entity_id` FROM `catalog_product_entity_int` AS `t1` LEFT JOIN `catalog_product_entity_int` AS `t2` ON t1.entity_id = t2.entity_id AND t1.attribute_id = t2.attribute_id AND t2.store_id='1' WHERE (t1.store_id = 0) AND (t1.attribute_id = 497) AND (IFNULL(t2.value, t1.value) IN ('0', '1')) AND ( t1.entity_id IN ( SELECT `t1`.`entity_id` FROM `catalog_product_entity_int` AS `t1` LEFT JOIN `catalog_product_entity_int` AS `t2` ON t1.entity_id = t2.entity_id AND t1.attribute_id = t2.attribute_id AND t2.store_id='1' WHERE (t1.store_id = 0) AND (t1.attribute_id = 496) AND (IFNULL(t2.value, t1.value) IN ('0', '1')) ) ) ) ) ) ) BIND: Array ( [attribute_498] => %ten% )
  • 9.
  • 10.
    Read(3) Relation database:SELECT * FROM Employee WHERE Name = ‘John’ AND Nationality = ‘English
  • 11.
    Read(4) Self Join: SELECT t1.ID as 'ID' t1.Value AS ‘Name’, t2.Value AS ‘Nationality’ t3.Value AS Birthday FROM EAV_Data t1 LEFT JOIN EAV_Data t2 ON t1.ID = t2.ID LEFT JOIN EAV_Data t3 ON t1.ID = t3.ID WHERE t1.Attribute = ‘Name’ AND t1.Value = ‘John’ AND t2.Attribute = ‘Nationality’ AND t2.Value = ‘English’ AND t3.Attribute = ‘Birthday
  • 12.
    Good Provides aflexible mechanism to record the attributes associated with any entity. This EAV design requires almost no consideration of the nature of the applicable hierarchical data and requires very little time to implement The database schema does not change when the model changes
  • 13.
    Bad The EAVtable doesn't provide a mechanism to create relationships between entities of different sub-types. The EAV table does nothing to provide a grouping of related entity types. The EAV table uses a VARCHAR column for all attribute values regardless if Dates, timestamps, integers, numerics or booleans would be more appropriate Inefficient queries. Where you would execute a simple query returning 20 columns from a single table, you end up with 20 self-joins, one for each column
  • 14.
    Solution Take alook at Magento Database Diagram
  • 15.
    EAV table withPivot (3) Pivot SELECT * FROM ( SELECT ID , [100] AS Name , [101] AS Birthday , [102] AS Nationality FROM ( SELECT ID, EntityID, AttributeID, Value FROM EAV_Table ) p PIVOT ( MAX (Value) FOR AttributeID IN ([100], [101], [102]) ) AS pvt ) WHERE Name = 'John' AND Nationality = 'English'
  • 16.
    When Recommend fromAmazon SimpleDB: Principally utilize index and query functions rather than more complex relational database functions Don’t want any administrative burden at all in managing their structured data Want a service that scales automatically up or down in response to demand, without user intervention Require the highest availability and can’t tolerate downtime for data backup or software maintenance
  • 17.

[8]ページ先頭

©2009-2025 Movatter.jp