O'Reilly logo

SQL Antipatterns by Bill Karwin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Antipattern: Use a Generic Attribute Table

The solution that appeals to some programmers when they need to support variable attributes is to create a second table, storing attributes as rows. See the diagram showing the two tables in Figure 10, EAV entity relationship. Each row in this attribute table has three columns:

  • The Entity. Typically this is a foreign key to a parent table that has one row per entity.

  • The Attribute. This is simply the name of a column in a conventional table, but in this new design, we have to identify the attribute on each given row.

  • The Value. Each entity has a value for each of its attributes.

    For example, a given bug is an entity we identify by its primary key value 1234. It has an attribute called status ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required