Solution: Model the Subtypes
If EAV seems like the right design, you should take a second look before you implement it. If you do some good old-fashioned analysis, you will probably find that your projectâs data can be modeled in a traditional table design more easily and with greater assurance of data integrity.
There are several ways to store such data without using EAV. Most solutions work best when you have a finite number of subtypes and you know the attribute of each subtype. Which solution is best to use depends on how you intend to query the data, so you should decide on a design on a case-by-case basis.
Several of these designs comes from Martin Fowlerâs book Patterns of Enterprise Application Architecture [Fow03].
Single Table ...
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.