June 2010
Intermediate to advanced
328 pages
7h 51m
English
It’s better to redesign your database to avoid the weaknesses of Polymorphic Associations but still support the data modeling you need. The following sections describe a few solutions that accommodate the data relationship but make better use of metadata to enforce integrity.
One solution to this antipattern is simple once you see the nature of the problem: Polymorphic Associations are backward.
A foreign key in the child table Comments can’t reference multiple parent tables, so instead, use multiple foreign keys to reference the Comments table. Create a separate intersection table for each parent table, and in each intersection table include a foreign key ...
Read now
Unlock full access