Entity–Attribute–Value (EAV) Model

Published: (February 10, 2026 at 12:22 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

The Entity–Attribute–Value (EAV) model is a database design pattern that lets you define entity attributes at runtime. It’s especially useful when:

  • Different records of the same entity have widely varying attributes.
  • Many attributes apply only to a small subset of records, leading to sparse data.
  • Adding new columns or storing lots of NULL values would be impractical.

Instead of creating a fixed column for every possible attribute, EAV stores attributes in separate rows and assigns values only when they apply to a specific entity instance.

Example: Content Management System (CMS)

A CMS often needs to handle pages, articles, or media items that can have very different sets of metadata. With an EAV approach you might have three tables:

TablePurpose
EntityStores each CMS item (e.g., a page or article) with a primary key.
AttributeDefines possible attributes (e.g., title, author, publish_date, seo_keywords).
ValueHolds the actual value for a given entity‑attribute pair, typically with columns like entity_id, attribute_id, and value.

When a new custom field is needed (e.g., “reading_time”), you simply add a row to the Attribute table—no schema change is required.

When to Use EAV

  • Frequently changing attributes – New attributes are added often.
  • Sparse data – Most entities use only a small subset of the available attributes.
  • Custom attributes – Administrators or users must define attributes at runtime without altering the database schema.

When Not to Use EAV

  • Stable, well‑defined attributes – If the set of attributes is fixed and changes rarely, a traditional relational schema is more efficient.
  • High‑performance requirements – EAV queries often involve multiple joins, which can degrade performance.
  • Complex reporting and analytics – Aggregating and analyzing data across many EAV rows is more difficult and slower than with a conventional table layout.

Practical Advice

  • Hybrid approach – Combine traditional tables for stable attributes with EAV tables for flexible, custom fields.
  • Index wisely – Index the entity_id and attribute_id columns in the Value table to improve join performance.
  • Limit scope – Use EAV only for entities that truly benefit from its flexibility; avoid applying it universally across the entire database.
0 views
Back to Blog

Related posts

Read more »

Primary & Secondary Keys In Power Bi.

!Cover image for Primary & Secondary Keys In Power Bi.https://media2.dev.to/dynamic/image/width=1000,height=420,fit=cover,gravity=auto,format=auto/https%3A%2F%2...