SlideShare una empresa de Scribd logo
1 de 16
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'
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
    ( cookie cutter)
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
 The isn't a way to prevent bad data-entry. For example
   nothing would prevent a user from entering 'I like peanut
   butter.' for the attribute value for Birthday
 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
EAV table with Pivot (2)
  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
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

Más contenido relacionado

La actualidad más candente

Dynamic Data Specification
Dynamic Data SpecificationDynamic Data Specification
Dynamic Data Specificationgtilton
 
Restrict user from use account aliases incompatible with transaction action
Restrict user from use account aliases incompatible with transaction actionRestrict user from use account aliases incompatible with transaction action
Restrict user from use account aliases incompatible with transaction actionAhmed Elshayeb
 
Wicket KT part 2
Wicket KT part 2Wicket KT part 2
Wicket KT part 2stuq
 
Personalizations for control deliver to organizations in Purchase Requisition...
Personalizations for control deliver to organizations in Purchase Requisition...Personalizations for control deliver to organizations in Purchase Requisition...
Personalizations for control deliver to organizations in Purchase Requisition...Ahmed Elshayeb
 

La actualidad más candente (13)

Db1 lecture4
Db1 lecture4Db1 lecture4
Db1 lecture4
 
Ecom lec4 fall16_jpa
Ecom lec4 fall16_jpaEcom lec4 fall16_jpa
Ecom lec4 fall16_jpa
 
Dump Answers
Dump AnswersDump Answers
Dump Answers
 
Dynamic Data Specification
Dynamic Data SpecificationDynamic Data Specification
Dynamic Data Specification
 
1 z0 047
1 z0 0471 z0 047
1 z0 047
 
Structures and Unions
Structures and UnionsStructures and Unions
Structures and Unions
 
Restrict user from use account aliases incompatible with transaction action
Restrict user from use account aliases incompatible with transaction actionRestrict user from use account aliases incompatible with transaction action
Restrict user from use account aliases incompatible with transaction action
 
REST API
REST APIREST API
REST API
 
Wicket KT part 2
Wicket KT part 2Wicket KT part 2
Wicket KT part 2
 
Sql ch 5
Sql ch 5Sql ch 5
Sql ch 5
 
About Array
About ArrayAbout Array
About Array
 
1 z1 051
1 z1 0511 z1 051
1 z1 051
 
Personalizations for control deliver to organizations in Purchase Requisition...
Personalizations for control deliver to organizations in Purchase Requisition...Personalizations for control deliver to organizations in Purchase Requisition...
Personalizations for control deliver to organizations in Purchase Requisition...
 

Similar a EAV in Magento

Entity Attribute Value (Eav)
Entity   Attribute   Value (Eav)Entity   Attribute   Value (Eav)
Entity Attribute Value (Eav)Tâm
 
MQSL JOINING OF TABLES.pptx
MQSL JOINING OF TABLES.pptxMQSL JOINING OF TABLES.pptx
MQSL JOINING OF TABLES.pptxlemonchoos
 
EAV Sytem- Magento EAV Model
EAV Sytem- Magento EAV ModelEAV Sytem- Magento EAV Model
EAV Sytem- Magento EAV ModelKhoa Truong Dinh
 
Program Specifications in c++ Develop an inventory management system f.docx
Program Specifications in c++ Develop an inventory management system f.docxProgram Specifications in c++ Develop an inventory management system f.docx
Program Specifications in c++ Develop an inventory management system f.docxsharold2
 
Program Specifications in c++ Develop an inventory management syste.docx
Program Specifications in c++    Develop an inventory management syste.docxProgram Specifications in c++    Develop an inventory management syste.docx
Program Specifications in c++ Develop an inventory management syste.docxsharold2
 
show code and all classes with full implementation for these Program S.pdf
show code and all classes with full implementation for these Program S.pdfshow code and all classes with full implementation for these Program S.pdf
show code and all classes with full implementation for these Program S.pdfAlanSmDDyerl
 
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQueryPPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQueryAbhishek590097
 
Begin with the InventoryItem class and InventoryDemo fronte.pdf
Begin with the InventoryItem class and InventoryDemo fronte.pdfBegin with the InventoryItem class and InventoryDemo fronte.pdf
Begin with the InventoryItem class and InventoryDemo fronte.pdfaartienterprises2014
 
Income Qualification ppt.pptx
Income Qualification ppt.pptxIncome Qualification ppt.pptx
Income Qualification ppt.pptxShilpaSweety2
 
BIS06 Physical Database Models
BIS06 Physical Database ModelsBIS06 Physical Database Models
BIS06 Physical Database ModelsPrithwis Mukerjee
 
BIS06 Physical Database Models
BIS06 Physical Database ModelsBIS06 Physical Database Models
BIS06 Physical Database ModelsPrithwis Mukerjee
 
on SQL Managment studio(For the following exercise, use the Week 5.pdf
on SQL Managment studio(For the following exercise, use the Week 5.pdfon SQL Managment studio(For the following exercise, use the Week 5.pdf
on SQL Managment studio(For the following exercise, use the Week 5.pdfformaxekochi
 
Program Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docxProgram Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docxVictormxrPiperc
 
]project-open[ Data-Model “Categories”
]project-open[ Data-Model “Categories”]project-open[ Data-Model “Categories”
]project-open[ Data-Model “Categories”Klaus Hofeditz
 
Arrays, Structures And Enums
Arrays, Structures And EnumsArrays, Structures And Enums
Arrays, Structures And EnumsBhushan Mulmule
 
Data Warehouse and Business Intelligence - Recipe 3
Data Warehouse and Business Intelligence - Recipe 3Data Warehouse and Business Intelligence - Recipe 3
Data Warehouse and Business Intelligence - Recipe 3Massimo Cenci
 
Assignment Two Objectives • Understand how the.docx
Assignment Two   Objectives • Understand how the.docxAssignment Two   Objectives • Understand how the.docx
Assignment Two Objectives • Understand how the.docxlynettearnold46882
 
Introduction to Dating Modeling for Cassandra
Introduction to Dating Modeling for CassandraIntroduction to Dating Modeling for Cassandra
Introduction to Dating Modeling for CassandraDataStax Academy
 

Similar a EAV in Magento (20)

Entity Attribute Value (Eav)
Entity   Attribute   Value (Eav)Entity   Attribute   Value (Eav)
Entity Attribute Value (Eav)
 
MQSL JOINING OF TABLES.pptx
MQSL JOINING OF TABLES.pptxMQSL JOINING OF TABLES.pptx
MQSL JOINING OF TABLES.pptx
 
EAV Sytem- Magento EAV Model
EAV Sytem- Magento EAV ModelEAV Sytem- Magento EAV Model
EAV Sytem- Magento EAV Model
 
Program Specifications in c++ Develop an inventory management system f.docx
Program Specifications in c++ Develop an inventory management system f.docxProgram Specifications in c++ Develop an inventory management system f.docx
Program Specifications in c++ Develop an inventory management system f.docx
 
Program Specifications in c++ Develop an inventory management syste.docx
Program Specifications in c++    Develop an inventory management syste.docxProgram Specifications in c++    Develop an inventory management syste.docx
Program Specifications in c++ Develop an inventory management syste.docx
 
show code and all classes with full implementation for these Program S.pdf
show code and all classes with full implementation for these Program S.pdfshow code and all classes with full implementation for these Program S.pdf
show code and all classes with full implementation for these Program S.pdf
 
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQueryPPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
 
Begin with the InventoryItem class and InventoryDemo fronte.pdf
Begin with the InventoryItem class and InventoryDemo fronte.pdfBegin with the InventoryItem class and InventoryDemo fronte.pdf
Begin with the InventoryItem class and InventoryDemo fronte.pdf
 
Income Qualification ppt.pptx
Income Qualification ppt.pptxIncome Qualification ppt.pptx
Income Qualification ppt.pptx
 
BIS06 Physical Database Models
BIS06 Physical Database ModelsBIS06 Physical Database Models
BIS06 Physical Database Models
 
BIS06 Physical Database Models
BIS06 Physical Database ModelsBIS06 Physical Database Models
BIS06 Physical Database Models
 
on SQL Managment studio(For the following exercise, use the Week 5.pdf
on SQL Managment studio(For the following exercise, use the Week 5.pdfon SQL Managment studio(For the following exercise, use the Week 5.pdf
on SQL Managment studio(For the following exercise, use the Week 5.pdf
 
Program Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docxProgram Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docx
 
ORM in Django
ORM in DjangoORM in Django
ORM in Django
 
]project-open[ Data-Model “Categories”
]project-open[ Data-Model “Categories”]project-open[ Data-Model “Categories”
]project-open[ Data-Model “Categories”
 
Arrays, Structures And Enums
Arrays, Structures And EnumsArrays, Structures And Enums
Arrays, Structures And Enums
 
занятие7
занятие7занятие7
занятие7
 
Data Warehouse and Business Intelligence - Recipe 3
Data Warehouse and Business Intelligence - Recipe 3Data Warehouse and Business Intelligence - Recipe 3
Data Warehouse and Business Intelligence - Recipe 3
 
Assignment Two Objectives • Understand how the.docx
Assignment Two   Objectives • Understand how the.docxAssignment Two   Objectives • Understand how the.docx
Assignment Two Objectives • Understand how the.docx
 
Introduction to Dating Modeling for Cassandra
Introduction to Dating Modeling for CassandraIntroduction to Dating Modeling for Cassandra
Introduction to Dating Modeling for Cassandra
 

Más de hazzaz

Coffee1
Coffee1Coffee1
Coffee1hazzaz
 
Suy ngam
Suy ngamSuy ngam
Suy ngamhazzaz
 
Tu dong dat hang tu he thong ban le lon nhat trung quoc
Tu dong dat hang tu he thong ban le lon nhat trung quocTu dong dat hang tu he thong ban le lon nhat trung quoc
Tu dong dat hang tu he thong ban le lon nhat trung quochazzaz
 
how startups can benefit from launch community
how startups can benefit from launch communityhow startups can benefit from launch community
how startups can benefit from launch communityhazzaz
 
social network game
social network gamesocial network game
social network gamehazzaz
 
trung oss magento overview
trung oss magento overviewtrung oss magento overview
trung oss magento overviewhazzaz
 
su dung drupal xay dung mang xa hoi
su dung drupal xay dung mang xa hoisu dung drupal xay dung mang xa hoi
su dung drupal xay dung mang xa hoihazzaz
 
html5 css3 the future of web technology
html5 css3 the future of web technologyhtml5 css3 the future of web technology
html5 css3 the future of web technologyhazzaz
 
java script unit testing framework
java script unit testing frameworkjava script unit testing framework
java script unit testing frameworkhazzaz
 
build your own php extension
build your own php extensionbuild your own php extension
build your own php extensionhazzaz
 
kiem tien online
kiem tien onlinekiem tien online
kiem tien onlinehazzaz
 
web optimization
web optimizationweb optimization
web optimizationhazzaz
 
speed up ntvv2 by php ext module
speed up ntvv2 by php ext modulespeed up ntvv2 by php ext module
speed up ntvv2 by php ext modulehazzaz
 
zingmepracticeforbuildingscalablewebsitewithphp
zingmepracticeforbuildingscalablewebsitewithphpzingmepracticeforbuildingscalablewebsitewithphp
zingmepracticeforbuildingscalablewebsitewithphphazzaz
 
mysql optimization
mysql optimizationmysql optimization
mysql optimizationhazzaz
 
css_trends
css_trendscss_trends
css_trendshazzaz
 
Phan mem tu do nguon mo
Phan mem tu do nguon moPhan mem tu do nguon mo
Phan mem tu do nguon mohazzaz
 

Más de hazzaz (20)

Coffee1
Coffee1Coffee1
Coffee1
 
Suy ngam
Suy ngamSuy ngam
Suy ngam
 
Tu dong dat hang tu he thong ban le lon nhat trung quoc
Tu dong dat hang tu he thong ban le lon nhat trung quocTu dong dat hang tu he thong ban le lon nhat trung quoc
Tu dong dat hang tu he thong ban le lon nhat trung quoc
 
how startups can benefit from launch community
how startups can benefit from launch communityhow startups can benefit from launch community
how startups can benefit from launch community
 
social network game
social network gamesocial network game
social network game
 
trung oss magento overview
trung oss magento overviewtrung oss magento overview
trung oss magento overview
 
su dung drupal xay dung mang xa hoi
su dung drupal xay dung mang xa hoisu dung drupal xay dung mang xa hoi
su dung drupal xay dung mang xa hoi
 
html5 css3 the future of web technology
html5 css3 the future of web technologyhtml5 css3 the future of web technology
html5 css3 the future of web technology
 
java script unit testing framework
java script unit testing frameworkjava script unit testing framework
java script unit testing framework
 
build your own php extension
build your own php extensionbuild your own php extension
build your own php extension
 
kiem tien online
kiem tien onlinekiem tien online
kiem tien online
 
web optimization
web optimizationweb optimization
web optimization
 
speed up ntvv2 by php ext module
speed up ntvv2 by php ext modulespeed up ntvv2 by php ext module
speed up ntvv2 by php ext module
 
zingmepracticeforbuildingscalablewebsitewithphp
zingmepracticeforbuildingscalablewebsitewithphpzingmepracticeforbuildingscalablewebsitewithphp
zingmepracticeforbuildingscalablewebsitewithphp
 
mysql optimization
mysql optimizationmysql optimization
mysql optimization
 
Albus
AlbusAlbus
Albus
 
css_trends
css_trendscss_trends
css_trends
 
Cloud
CloudCloud
Cloud
 
Phan mem tu do nguon mo
Phan mem tu do nguon moPhan mem tu do nguon mo
Phan mem tu do nguon mo
 
Zing
ZingZing
Zing
 

Último

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 

Último (20)

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 

EAV in Magento

  • 1. Entity - Attribute - Value (EAV) Data Model in Magento @Pờ Đình Tâm
  • 2. 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.
  • 3. Traditional User Table  table: user_entity
  • 5. 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
  • 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: DELETE FROM `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'
  • 9. 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 ( cookie cutter)
  • 10. 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  The isn't a way to prevent bad data-entry. For example nothing would prevent a user from entering 'I like peanut butter.' for the attribute value for Birthday  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
  • 11. Solution  Take a look at Magento Database Diagram
  • 12. EAV table with Pivot
  • 13. EAV table with Pivot (2)  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
  • 14. 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'
  • 15. 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
  • 16. Thanks for your attention