How to Recognize the Antipattern
If you hear people use phrases like the following, they’re probably practicing the Keyless Entry antipattern:
-
“How do I query to check for a value that exists in one table and not the other table?”
Usually this is to find orphan child rows whose parent has been updated or deleted.
-
“Is there a quick way to check that a value exists in one table as part of my insert to a second table?”
This is to ensure that the parent row exists. A foreign key does this for you automatically and uses any index on the parent table to make the check as efficient as possible.
-
“Foreign keys? I was told not to use them because they slow down the database.”
Performance is often used as a justification for cutting corners, ...
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