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. As you can see in the following figure, it looks simpler at first because you can use two tables instead of three (or more, if your data model has more variations).
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, you have to identify the attribute on each given ...
Get SQL Antipatterns, Volume 1 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.