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

EAV Tables 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.

ColumnTypeDescription
entity_type_idsmallintPrimary key
entity_type_codevarcharUnique code for the entity type
entity_modelvarcharPHP class that handles this entity type

eav_attribute

Defines attributes for all entity types.

ColumnTypeDescription
attribute_idsmallintPrimary key
entity_type_idsmallintForeign key to eav_entity_type.entity_type_id
attribute_codevarcharUnique code (e.g., 'name', 'price')

Attribute Option Tables

eav_attribute_option

Defines options for dropdown and multiselect attributes.

ColumnTypeDescription
option_idintPrimary key
attribute_idsmallintForeign key to eav_attribute.attribute_id
sort_ordersmallintDisplay 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