How to Recognize the Antipattern
The symptom of this antipattern is easy to recognize: tables use the overly generic name id for the primary key. There’s virtually no reason to prefer this column name over one that is more descriptive.
The following can also be evidence of the antipattern:
-
“I don’t think I need a primary key in this table.”
The developer who says this is confusing the term primary key with pseudokey. Every table must have a primary key constraint to prevent duplicate rows and identify individual rows. They might want to use a natural key or a compound key instead.
-
“How did I get duplicate many-to-many associations?”
An intersection table for a many-to-many relationship should declare a primary key constraint, or at ...
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