SlideShare ist ein Scribd-Unternehmen logo
1 von 29
WAS IST EIGENTLICH EAV?
        Eine Einführung in das Entity-Attribute-Value Model



                                  PHP User Group Rheinhessen
                                       12.01.2010 Mainz




Daniel Nitz — www.danielnitz.de               1                12.01.2010 — PHPUG-RHH
AGENDA

          1. Definition                  4. Nachteile

          2. Anwendungsbeispiel         5. In der Praxis

          3. Vorteile                   6. Fazit



Daniel Nitz — www.danielnitz.de     2              12.01.2010 — PHPUG-RHH
DEFINITION




Daniel Nitz — www.danielnitz.de       3        12.01.2010 — PHPUG-RHH
DEFINITION


  Entity-Attribute-Value Model, auch bekannt als Object-
  Attribute-Value Model und Open Schema ist ein Datenmodell,
  welches dann zum Einsatz kommt, wenn die Anzahl der
  Attribute (Eigenschaften, Parameter) zur Beschreibung einer
  Sache (Entität oder Objekt) im Vorfeld nicht vorhersehbar sind.



Daniel Nitz — www.danielnitz.de       4           12.01.2010 — PHPUG-RHH
DEFINITION



  EAV ist ein Datenmodell für den Fall, dass die Anzahl der
  Attribute eines Objektes nicht vorhersehbar sind.




Daniel Nitz — www.danielnitz.de       5           12.01.2010 — PHPUG-RHH
DEFINITION


  Entity: Repräsentiert einen Datensatz, z.B. eine Produkt.

  Attribute: Stellt eine Eigenschaft dar, z.B. Größe, Farbe etc.

  Value: Beinhaltet den Eigenschaftswert, z.B. XL, blau etc.



Daniel Nitz — www.danielnitz.de       6                12.01.2010 — PHPUG-RHH
DEFINITION

                                  1:n               1:1
                  Entity                Attribute            Value




                       3 Tabellen verknüpft mittels Foreign Keys.



Daniel Nitz — www.danielnitz.de             7                12.01.2010 — PHPUG-RHH
HÄ?



Daniel Nitz — www.danielnitz.de    8    12.01.2010 — PHPUG-RHH
ANWENDUNGSBEISPIEL
           Unterschied EAV im Vergleich zum relationalen Design




Daniel Nitz — www.danielnitz.de     9                 12.01.2010 — PHPUG-RHH
ANWENDUNGSBEISPIEL

‣   Eine Person wird anhand einer eindeutigen Nummer
    identifiziert

‣   Eine Person hat einen Vornamen

‣   Eine Person hat einen Nachnamen

‣   Ein Person hat eine beliebige Anzahl von zusätzlichen
    Informationen (Alter, Gewicht, Größe etc.)
Daniel Nitz — www.danielnitz.de   10                12.01.2010 — PHPUG-RHH
RELATIONALES DESIGN
                                   Person             Data

                                  person_id   1:1   person_id
                                  first_name         age
                                  last_name         weight
                                                    height




Daniel Nitz — www.danielnitz.de               11                12.01.2010 — PHPUG-RHH
EAV DESIGN

                  Entity                  Attribute               Value
                                                         1:1
               entity_id          1:n
                                        attribute_id           attribute_id
                                        entity_id              value
                                        attribute_name




Daniel Nitz — www.danielnitz.de               12                 12.01.2010 — PHPUG-RHH
STORY
Relationales Design:
Die Person mit der Nummer 1 hat das Alter 30, hat ein Gewicht von 80,
hat eine Größe von 180.


EAV Design:
Die Person mit der Nummer 1 hat das Attribut Alter mit dem Wert 30.

Die Person mit der Nummer 1 hat das Attribut Gewicht mit dem Wert 80.

Die Person mit der Nummer 1 hat das Attribut Größe mit dem Wert 180.

 Daniel Nitz — www.danielnitz.de     13                 12.01.2010 — PHPUG-RHH
DESIGN PROBLEME


‣   keine Datentypen

‣   keine definierten Spalten-/Attributsets

‣   Redundanz von Attributen

‣   keine Integrität


Daniel Nitz — www.danielnitz.de   14         12.01.2010 — PHPUG-RHH
EAV DESIGN

                  Entity                  Attribute                            Value
                                                               1:1
               entity_id          1:n
                                        attribute_id                        attribute_id
                                        entity_id                           value_id
                                        attribute_name

                                                         1:1                            1:1



                                                                Value Int                Value ...

                                                               value_id                value_id
                                                               value                   value


Daniel Nitz — www.danielnitz.de               15                              12.01.2010 — PHPUG-RHH
EAV DESIGN

                  Entity                    Entity_Attribute                         Value
                                                                     1:1
               entity_id          1:n
                                            ea_id                                 ea_id
                                            entity_id                             value_id
                                            attribute_id
                                            as_id
                                                               1:1                            1:1



               Attribute Set              Attribute                   Value Int                Value ...

             as_id                      attribute_id                 value_id                value_id
             as_name                    attribute_name               value                   value


Daniel Nitz — www.danielnitz.de                   16                                12.01.2010 — PHPUG-RHH
DESIGN PROBLEME


‣   verschiedene Datentypen

‣   definierte Spalten-/Attributsets

‣   keine Redundanz von Attributen

‣   Integrität gewahrt


Daniel Nitz — www.danielnitz.de   17   12.01.2010 — PHPUG-RHH
VORTEILE




Daniel Nitz — www.danielnitz.de      18      12.01.2010 — PHPUG-RHH
VORTEILE


‣   Hohe Flexibilität in der Gestaltung von Objektstrukturen

‣   Kein DBA zur Änderung der Schemata nötig

‣   Keine zusätzliche Programmierung bei Änderung der
    Schemata nötig


Daniel Nitz — www.danielnitz.de      19            12.01.2010 — PHPUG-RHH
NACHTEILE




Daniel Nitz — www.danielnitz.de       20      12.01.2010 — PHPUG-RHH
NACHTEILE


‣   Hohe Systemlast durch komplizierte SQL Queries

‣   Komplexe Programmierung von SQL Statements

‣   Verlust von DBMS-spezifischen Funktionalitäten

‣   Verlagerung von DBMS-Funktionen in die Anwendungslogik


Daniel Nitz — www.danielnitz.de       21            12.01.2010 — PHPUG-RHH
IN DER PRAXIS




Daniel Nitz — www.danielnitz.de         22        12.01.2010 — PHPUG-RHH
EAV MODEL LIBRARY

Dmg_Db_Eav:
‣   EAV Model Implementierung für das Zend Framework

‣   Auf Basis von Zend_Db und Zend_Db_Table

‣   Nutzung von Zend_Cache



Daniel Nitz — www.danielnitz.de   23          12.01.2010 — PHPUG-RHH
CODE BEISPIEL

 $options = new Dmg_Db_Eav_Config($array);

 // Person implements Dmg_Db_Eav_Abstract
 $personModel = new Person($options);

 $persons = $personModel->addAttributeFilter('age', 30)
    	 	 	 	 	           ->addAttributeFilter('name', 'daniel')
                        ->addFilter('active', 1)
                        ->addLimit(10)
                        ->load();




Daniel Nitz — www.danielnitz.de         24         12.01.2010 — PHPUG-RHH
CODE BEISPIEL
foreach ($persons as $person) {
	 $attributes = $person->getAttributes();
	 foreach ($attributes as $attribute) {
	 	 if (!$attribute->hasOptions()) {
	 	 	 echo $attribute->getName() . ': ' . $attribute->getValue();
	 	 } else {
	 	 	 foreach ($attribute->getOptions() as $option) {
	 	 	 	 echo $option->getName() . ': ' . $option->getValue();
	 	 	 }
	 	 }
	 }
}



Daniel Nitz — www.danielnitz.de         25        12.01.2010 — PHPUG-RHH
PERFORMANCE
 #            Time                                                                         Query
 1     0.223762989044    connect

                         SELECT `e`.*, `v`.*, `a`.*, `as`.*, `g`.*, `ga`.* FROM `eav_entity` AS `e` INNER JOIN `eav_value` AS `v` ON e.entity_id = v.entity_id INNER
                         JOIN `eav_attribute` AS `a` ON v.attribute_id = a.attribute_id INNER JOIN `eav_attribute_set` AS `as` ON e.attribute_set_id =
 2     0.42297410965
                         as.attribute_set_id INNER JOIN `eav_attribute_group` AS `g` ON g.attribute_set_id = as.attribute_set_id INNER JOIN
                         `eav_attribute_group_attribute` AS `ga` ON a.attribute_id = ga.attribute_id WHERE (e.entity_id = 1)

 3     0.0507569313049   DESCRIBE `eav_entity`

                         SELECT eav_value_varchar.*, CONCAT('varchar') AS type FROM eav_value_varchar WHERE value_id IN (1, 3) UNION SELECT
 4     0.757645130157    eav_value_int.*, CONCAT('int') AS type FROM eav_value_int WHERE value_id IN (2) UNION SELECT eav_value_text.*, CONCAT('text') AS
                         type FROM eav_value_text WHERE value_id IN (4)


 ...            ...                                                                           ...



Query Zeit beim Laden eines EAV Objektes ohne Cache mit 4
Attributen, eines davon hat 6 Attributoptionen: 1.949 sec
Nach dem Caching: 0.079 sec
Daniel Nitz — www.danielnitz.de                                             26                                                  12.01.2010 — PHPUG-RHH
FAZIT




Daniel Nitz — www.danielnitz.de     27    12.01.2010 — PHPUG-RHH
FAZIT

‣   EAV bietet gute Möglichkeiten eine Anwendung in der
    Datenschicht flexibel zu halten.

‣   Es gibt jedoch nur wenige Anwendungsfälle, in denen eine EAV
    Implementierung wirklich sinnvoll ist.

‣   Ein relationales Design sollte dem EAV, wenn möglich,
    vorgezogen werden.

Daniel Nitz — www.danielnitz.de     28             12.01.2010 — PHPUG-RHH
VIELEN DANK!

                                            Daniel Nitz
                                            [ zend certified engineer ]

                                            daniel@danielnitz.de
                                            twitter.com/danielnitz




Daniel Nitz — www.danielnitz.de        29                 12.01.2010 — PHPUG-RHH

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction à la big data V2
Introduction à la big data V2Introduction à la big data V2
Introduction à la big data V2Mehdi TAZI
 
Graph Analytics with ArangoDB
Graph Analytics with ArangoDBGraph Analytics with ArangoDB
Graph Analytics with ArangoDBArangoDB Database
 
Integration de donnees_etl
Integration de donnees_etlIntegration de donnees_etl
Integration de donnees_etlhoracio lassey
 
Introduction aux bases de données NoSQL
Introduction aux bases de données NoSQLIntroduction aux bases de données NoSQL
Introduction aux bases de données NoSQLAntoine Augusti
 
Büyük veri teknolojilerine giriş v1l
Büyük veri teknolojilerine giriş v1lBüyük veri teknolojilerine giriş v1l
Büyük veri teknolojilerine giriş v1lHakan Ilter
 
Big Data : concepts, cas d'usage et tendances
Big Data : concepts, cas d'usage et tendancesBig Data : concepts, cas d'usage et tendances
Big Data : concepts, cas d'usage et tendancesJean-Michel Franco
 
03 Apprentissage statistique
03 Apprentissage statistique03 Apprentissage statistique
03 Apprentissage statistiqueBoris Guarisma
 
Introduction au web sémantique
Introduction au web sémantiqueIntroduction au web sémantique
Introduction au web sémantiqueStéphane Traumat
 
Apache NiFi Meetup - Introduction to NiFi Registry
Apache NiFi Meetup - Introduction to NiFi RegistryApache NiFi Meetup - Introduction to NiFi Registry
Apache NiFi Meetup - Introduction to NiFi RegistryBryan Bende
 
Dojo 02 : Introduction au noSQL
Dojo 02 : Introduction au noSQLDojo 02 : Introduction au noSQL
Dojo 02 : Introduction au noSQLSOAT
 
OFFRE DE RESPONSABILITES : GESTIONNAIRE DE SINISTRES
OFFRE DE RESPONSABILITES : GESTIONNAIRE DE SINISTRESOFFRE DE RESPONSABILITES : GESTIONNAIRE DE SINISTRES
OFFRE DE RESPONSABILITES : GESTIONNAIRE DE SINISTRESNelly KERBIRIOU
 
Les modèles NoSQL
Les modèles NoSQLLes modèles NoSQL
Les modèles NoSQLebiznext
 
Cours Big Data Chap6
Cours Big Data Chap6Cours Big Data Chap6
Cours Big Data Chap6Amal Abid
 

Was ist angesagt? (20)

Introduction à la big data V2
Introduction à la big data V2Introduction à la big data V2
Introduction à la big data V2
 
Data mining - Associativité
Data mining - AssociativitéData mining - Associativité
Data mining - Associativité
 
Graph Analytics with ArangoDB
Graph Analytics with ArangoDBGraph Analytics with ArangoDB
Graph Analytics with ArangoDB
 
Integration de donnees_etl
Integration de donnees_etlIntegration de donnees_etl
Integration de donnees_etl
 
Application d'analyses des Tweets
Application d'analyses des TweetsApplication d'analyses des Tweets
Application d'analyses des Tweets
 
Une Introduction à R
Une Introduction à RUne Introduction à R
Une Introduction à R
 
Introduction aux bases de données NoSQL
Introduction aux bases de données NoSQLIntroduction aux bases de données NoSQL
Introduction aux bases de données NoSQL
 
Büyük veri teknolojilerine giriş v1l
Büyük veri teknolojilerine giriş v1lBüyük veri teknolojilerine giriş v1l
Büyük veri teknolojilerine giriş v1l
 
Big Data : concepts, cas d'usage et tendances
Big Data : concepts, cas d'usage et tendancesBig Data : concepts, cas d'usage et tendances
Big Data : concepts, cas d'usage et tendances
 
Technologies pour le Big Data
Technologies pour le Big DataTechnologies pour le Big Data
Technologies pour le Big Data
 
03 Apprentissage statistique
03 Apprentissage statistique03 Apprentissage statistique
03 Apprentissage statistique
 
MPP vs Hadoop
MPP vs HadoopMPP vs Hadoop
MPP vs Hadoop
 
Introduction au web sémantique
Introduction au web sémantiqueIntroduction au web sémantique
Introduction au web sémantique
 
Apache NiFi Meetup - Introduction to NiFi Registry
Apache NiFi Meetup - Introduction to NiFi RegistryApache NiFi Meetup - Introduction to NiFi Registry
Apache NiFi Meetup - Introduction to NiFi Registry
 
Dojo 02 : Introduction au noSQL
Dojo 02 : Introduction au noSQLDojo 02 : Introduction au noSQL
Dojo 02 : Introduction au noSQL
 
OFFRE DE RESPONSABILITES : GESTIONNAIRE DE SINISTRES
OFFRE DE RESPONSABILITES : GESTIONNAIRE DE SINISTRESOFFRE DE RESPONSABILITES : GESTIONNAIRE DE SINISTRES
OFFRE DE RESPONSABILITES : GESTIONNAIRE DE SINISTRES
 
Data Warehouse
Data WarehouseData Warehouse
Data Warehouse
 
Les modèles NoSQL
Les modèles NoSQLLes modèles NoSQL
Les modèles NoSQL
 
Ch 01 poo
Ch 01 pooCh 01 poo
Ch 01 poo
 
Cours Big Data Chap6
Cours Big Data Chap6Cours Big Data Chap6
Cours Big Data Chap6
 

Andere mochten auch

Entity Attribute Value (Eav)
Entity   Attribute   Value (Eav)Entity   Attribute   Value (Eav)
Entity Attribute Value (Eav)Tâm
 
Dare to build vertical design with relational data (Entity-Attribute-Value)
Dare to build vertical design with relational data (Entity-Attribute-Value)Dare to build vertical design with relational data (Entity-Attribute-Value)
Dare to build vertical design with relational data (Entity-Attribute-Value)Ivo Andreev
 
Best Practices: Datawarehouse Automation Conference September 20, 2012 - Amst...
Best Practices: Datawarehouse Automation Conference September 20, 2012 - Amst...Best Practices: Datawarehouse Automation Conference September 20, 2012 - Amst...
Best Practices: Datawarehouse Automation Conference September 20, 2012 - Amst...Erik Fransen
 
Implementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord modelsImplementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord modelsKostyantyn Stepanyuk
 
Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...
Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...
Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...Roland Bouman
 
Data warehouse architecture
Data warehouse architectureData warehouse architecture
Data warehouse architecturepcherukumalla
 
Data Warehouse Design and Best Practices
Data Warehouse Design and Best PracticesData Warehouse Design and Best Practices
Data Warehouse Design and Best PracticesIvo Andreev
 
Building an Effective Data Warehouse Architecture
Building an Effective Data Warehouse ArchitectureBuilding an Effective Data Warehouse Architecture
Building an Effective Data Warehouse ArchitectureJames Serra
 

Andere mochten auch (13)

Eav Data Model Concepts
Eav Data Model ConceptsEav Data Model Concepts
Eav Data Model Concepts
 
Entity Attribute Value (Eav)
Entity   Attribute   Value (Eav)Entity   Attribute   Value (Eav)
Entity Attribute Value (Eav)
 
Extensible Data Modeling
Extensible Data ModelingExtensible Data Modeling
Extensible Data Modeling
 
Dare to build vertical design with relational data (Entity-Attribute-Value)
Dare to build vertical design with relational data (Entity-Attribute-Value)Dare to build vertical design with relational data (Entity-Attribute-Value)
Dare to build vertical design with relational data (Entity-Attribute-Value)
 
Best Practices: Datawarehouse Automation Conference September 20, 2012 - Amst...
Best Practices: Datawarehouse Automation Conference September 20, 2012 - Amst...Best Practices: Datawarehouse Automation Conference September 20, 2012 - Amst...
Best Practices: Datawarehouse Automation Conference September 20, 2012 - Amst...
 
Practical Object Oriented Models In Sql
Practical Object Oriented Models In SqlPractical Object Oriented Models In Sql
Practical Object Oriented Models In Sql
 
Implementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord modelsImplementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord models
 
Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...
Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...
Roland bouman modern_data_warehouse_architectures_data_vault_and_anchor_model...
 
SQL Outer Joins for Fun and Profit
SQL Outer Joins for Fun and ProfitSQL Outer Joins for Fun and Profit
SQL Outer Joins for Fun and Profit
 
Modern Data Architecture
Modern Data ArchitectureModern Data Architecture
Modern Data Architecture
 
Data warehouse architecture
Data warehouse architectureData warehouse architecture
Data warehouse architecture
 
Data Warehouse Design and Best Practices
Data Warehouse Design and Best PracticesData Warehouse Design and Best Practices
Data Warehouse Design and Best Practices
 
Building an Effective Data Warehouse Architecture
Building an Effective Data Warehouse ArchitectureBuilding an Effective Data Warehouse Architecture
Building an Effective Data Warehouse Architecture
 

Was ist eigentlich EAV?

  • 1. WAS IST EIGENTLICH EAV? Eine Einführung in das Entity-Attribute-Value Model PHP User Group Rheinhessen 12.01.2010 Mainz Daniel Nitz — www.danielnitz.de 1 12.01.2010 — PHPUG-RHH
  • 2. AGENDA 1. Definition 4. Nachteile 2. Anwendungsbeispiel 5. In der Praxis 3. Vorteile 6. Fazit Daniel Nitz — www.danielnitz.de 2 12.01.2010 — PHPUG-RHH
  • 3. DEFINITION Daniel Nitz — www.danielnitz.de 3 12.01.2010 — PHPUG-RHH
  • 4. DEFINITION Entity-Attribute-Value Model, auch bekannt als Object- Attribute-Value Model und Open Schema ist ein Datenmodell, welches dann zum Einsatz kommt, wenn die Anzahl der Attribute (Eigenschaften, Parameter) zur Beschreibung einer Sache (Entität oder Objekt) im Vorfeld nicht vorhersehbar sind. Daniel Nitz — www.danielnitz.de 4 12.01.2010 — PHPUG-RHH
  • 5. DEFINITION EAV ist ein Datenmodell für den Fall, dass die Anzahl der Attribute eines Objektes nicht vorhersehbar sind. Daniel Nitz — www.danielnitz.de 5 12.01.2010 — PHPUG-RHH
  • 6. DEFINITION Entity: Repräsentiert einen Datensatz, z.B. eine Produkt. Attribute: Stellt eine Eigenschaft dar, z.B. Größe, Farbe etc. Value: Beinhaltet den Eigenschaftswert, z.B. XL, blau etc. Daniel Nitz — www.danielnitz.de 6 12.01.2010 — PHPUG-RHH
  • 7. DEFINITION 1:n 1:1 Entity Attribute Value 3 Tabellen verknüpft mittels Foreign Keys. Daniel Nitz — www.danielnitz.de 7 12.01.2010 — PHPUG-RHH
  • 8. HÄ? Daniel Nitz — www.danielnitz.de 8 12.01.2010 — PHPUG-RHH
  • 9. ANWENDUNGSBEISPIEL Unterschied EAV im Vergleich zum relationalen Design Daniel Nitz — www.danielnitz.de 9 12.01.2010 — PHPUG-RHH
  • 10. ANWENDUNGSBEISPIEL ‣ Eine Person wird anhand einer eindeutigen Nummer identifiziert ‣ Eine Person hat einen Vornamen ‣ Eine Person hat einen Nachnamen ‣ Ein Person hat eine beliebige Anzahl von zusätzlichen Informationen (Alter, Gewicht, Größe etc.) Daniel Nitz — www.danielnitz.de 10 12.01.2010 — PHPUG-RHH
  • 11. RELATIONALES DESIGN Person Data person_id 1:1 person_id first_name age last_name weight height Daniel Nitz — www.danielnitz.de 11 12.01.2010 — PHPUG-RHH
  • 12. EAV DESIGN Entity Attribute Value 1:1 entity_id 1:n attribute_id attribute_id entity_id value attribute_name Daniel Nitz — www.danielnitz.de 12 12.01.2010 — PHPUG-RHH
  • 13. STORY Relationales Design: Die Person mit der Nummer 1 hat das Alter 30, hat ein Gewicht von 80, hat eine Größe von 180. EAV Design: Die Person mit der Nummer 1 hat das Attribut Alter mit dem Wert 30. Die Person mit der Nummer 1 hat das Attribut Gewicht mit dem Wert 80. Die Person mit der Nummer 1 hat das Attribut Größe mit dem Wert 180. Daniel Nitz — www.danielnitz.de 13 12.01.2010 — PHPUG-RHH
  • 14. DESIGN PROBLEME ‣ keine Datentypen ‣ keine definierten Spalten-/Attributsets ‣ Redundanz von Attributen ‣ keine Integrität Daniel Nitz — www.danielnitz.de 14 12.01.2010 — PHPUG-RHH
  • 15. EAV DESIGN Entity Attribute Value 1:1 entity_id 1:n attribute_id attribute_id entity_id value_id attribute_name 1:1 1:1 Value Int Value ... value_id value_id value value Daniel Nitz — www.danielnitz.de 15 12.01.2010 — PHPUG-RHH
  • 16. EAV DESIGN Entity Entity_Attribute Value 1:1 entity_id 1:n ea_id ea_id entity_id value_id attribute_id as_id 1:1 1:1 Attribute Set Attribute Value Int Value ... as_id attribute_id value_id value_id as_name attribute_name value value Daniel Nitz — www.danielnitz.de 16 12.01.2010 — PHPUG-RHH
  • 17. DESIGN PROBLEME ‣ verschiedene Datentypen ‣ definierte Spalten-/Attributsets ‣ keine Redundanz von Attributen ‣ Integrität gewahrt Daniel Nitz — www.danielnitz.de 17 12.01.2010 — PHPUG-RHH
  • 18. VORTEILE Daniel Nitz — www.danielnitz.de 18 12.01.2010 — PHPUG-RHH
  • 19. VORTEILE ‣ Hohe Flexibilität in der Gestaltung von Objektstrukturen ‣ Kein DBA zur Änderung der Schemata nötig ‣ Keine zusätzliche Programmierung bei Änderung der Schemata nötig Daniel Nitz — www.danielnitz.de 19 12.01.2010 — PHPUG-RHH
  • 20. NACHTEILE Daniel Nitz — www.danielnitz.de 20 12.01.2010 — PHPUG-RHH
  • 21. NACHTEILE ‣ Hohe Systemlast durch komplizierte SQL Queries ‣ Komplexe Programmierung von SQL Statements ‣ Verlust von DBMS-spezifischen Funktionalitäten ‣ Verlagerung von DBMS-Funktionen in die Anwendungslogik Daniel Nitz — www.danielnitz.de 21 12.01.2010 — PHPUG-RHH
  • 22. IN DER PRAXIS Daniel Nitz — www.danielnitz.de 22 12.01.2010 — PHPUG-RHH
  • 23. EAV MODEL LIBRARY Dmg_Db_Eav: ‣ EAV Model Implementierung für das Zend Framework ‣ Auf Basis von Zend_Db und Zend_Db_Table ‣ Nutzung von Zend_Cache Daniel Nitz — www.danielnitz.de 23 12.01.2010 — PHPUG-RHH
  • 24. CODE BEISPIEL $options = new Dmg_Db_Eav_Config($array); // Person implements Dmg_Db_Eav_Abstract $personModel = new Person($options); $persons = $personModel->addAttributeFilter('age', 30) ->addAttributeFilter('name', 'daniel') ->addFilter('active', 1) ->addLimit(10) ->load(); Daniel Nitz — www.danielnitz.de 24 12.01.2010 — PHPUG-RHH
  • 25. CODE BEISPIEL foreach ($persons as $person) { $attributes = $person->getAttributes(); foreach ($attributes as $attribute) { if (!$attribute->hasOptions()) { echo $attribute->getName() . ': ' . $attribute->getValue(); } else { foreach ($attribute->getOptions() as $option) { echo $option->getName() . ': ' . $option->getValue(); } } } } Daniel Nitz — www.danielnitz.de 25 12.01.2010 — PHPUG-RHH
  • 26. PERFORMANCE # Time Query 1 0.223762989044 connect SELECT `e`.*, `v`.*, `a`.*, `as`.*, `g`.*, `ga`.* FROM `eav_entity` AS `e` INNER JOIN `eav_value` AS `v` ON e.entity_id = v.entity_id INNER JOIN `eav_attribute` AS `a` ON v.attribute_id = a.attribute_id INNER JOIN `eav_attribute_set` AS `as` ON e.attribute_set_id = 2 0.42297410965 as.attribute_set_id INNER JOIN `eav_attribute_group` AS `g` ON g.attribute_set_id = as.attribute_set_id INNER JOIN `eav_attribute_group_attribute` AS `ga` ON a.attribute_id = ga.attribute_id WHERE (e.entity_id = 1) 3 0.0507569313049 DESCRIBE `eav_entity` SELECT eav_value_varchar.*, CONCAT('varchar') AS type FROM eav_value_varchar WHERE value_id IN (1, 3) UNION SELECT 4 0.757645130157 eav_value_int.*, CONCAT('int') AS type FROM eav_value_int WHERE value_id IN (2) UNION SELECT eav_value_text.*, CONCAT('text') AS type FROM eav_value_text WHERE value_id IN (4) ... ... ... Query Zeit beim Laden eines EAV Objektes ohne Cache mit 4 Attributen, eines davon hat 6 Attributoptionen: 1.949 sec Nach dem Caching: 0.079 sec Daniel Nitz — www.danielnitz.de 26 12.01.2010 — PHPUG-RHH
  • 27. FAZIT Daniel Nitz — www.danielnitz.de 27 12.01.2010 — PHPUG-RHH
  • 28. FAZIT ‣ EAV bietet gute Möglichkeiten eine Anwendung in der Datenschicht flexibel zu halten. ‣ Es gibt jedoch nur wenige Anwendungsfälle, in denen eine EAV Implementierung wirklich sinnvoll ist. ‣ Ein relationales Design sollte dem EAV, wenn möglich, vorgezogen werden. Daniel Nitz — www.danielnitz.de 28 12.01.2010 — PHPUG-RHH
  • 29. VIELEN DANK! Daniel Nitz [ zend certified engineer ] daniel@danielnitz.de twitter.com/danielnitz Daniel Nitz — www.danielnitz.de 29 12.01.2010 — PHPUG-RHH