EAV (Entity-Attribute-Value) Database Structure
What is EAV?
In a traditional database design, each attribute of an entity would be a column in a table. In the EAV model, attributes are stored as rows in separate tables, allowing for dynamic attributes and flexibility.
Key Relationships
Note: This is a simplified diagram showing the main relationships.
Core EAV Tables
eav_entity_type
Defines the entity types that use the EAV model.
| Column | Type | Description | 
|---|---|---|
| entity_type_id | smallint | Primary key | 
| entity_type_code | varchar | Unique code for the entity type | 
| entity_model | varchar | PHP class that handles this entity type | 
eav_attribute
Defines attributes for all entity types.
| Column | Type | Description | 
|---|---|---|
| attribute_id | smallint | Primary key | 
| entity_type_id | smallint | Foreign key to eav_entity_type.entity_type_id | 
| attribute_code | varchar | Unique code (e.g., 'name', 'price') | 
Attribute Option Tables
eav_attribute_option
Defines options for dropdown and multiselect attributes.
| Column | Type | Description | 
|---|---|---|
| option_id | int | Primary key | 
| attribute_id | smallint | Foreign key to eav_attribute.attribute_id | 
| sort_order | smallint | Display order | 
Data Analysis Tips
- Find product attributes via eav_attribute filtered by entity_type_id for catalog_product
- Join value tables (varchar/int/decimal/datetime/text) for complete entity info
