...
/Synopsis: Polymorphic Associations
Synopsis: Polymorphic Associations
Let’s look at an antipattern that originates from multiple inheritance relationships.
We'll cover the following...
We'll cover the following...
Let’s allow users to make comments on bugs. A given bug may have many comments, but any given comment must pertain to a single bug. So, there’s a one-to-many relationship between Bugs and Comments. The Entity-Relationship Diagram for this kind of simple association is shown below.
The following SQL shows how we would create this table:
However, we may have two tables we can comment on. Bugs and FeatureRequests are similar entities, although we may store them as separate tables (see Concrete ...