How to Recognize the Antipattern
If you hear statements like the following, it’s a clue that the Polymorphic Associations antipattern is being employed:
-
“This tagging schema allows you to associate a tag (or other attribute) with any other resource in the database.”
As in EAV, you should be suspicious of any claims of unlimited flexibility.
-
“You can’t declare foreign keys in our database design.”
This is another red flag. Foreign keys are a fundamental feature of relational databases, and a design that can’t work with proper referential integrity has a lot of problems.
-
“What’s the entity_type column for? Oh, that tells you which thing this other column points to.”
Any foreign key must reference the same table on all rows.
The Ruby ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access