Book
SQL Antipatterns, Volume 1
Avoiding the Pitfalls of Database Programming
Bill Karwin
Summary
Bill Karwin built this from patterns he kept seeing in thousands of requests for SQL help: developers aren't usually SQL experts, and the SQL that gets written tends toward a small set of recurring, avoidable mistakes. Each of the 25 chapters names one antipattern, the Naive Tree for storing hierarchical data, Entity-Attribute-Value for flexible schemas, Polymorphic Associations, explains why it seems reasonable and where it breaks down, then walks through the fix and the relational theory behind it. This second edition, supervised in translation by Takuto Wada, updates the original for current database practice, and reads well both as something to skim for a name you recognize in your own schema and as something to read straight through to build design instincts.
Target Readers
- Developers who want a design vocabulary sharp enough to name specific problems in code review, not just say something feels wrong
- Engineers designing a schema who keep reaching for entity-attribute-value or polymorphic associations and want the tradeoffs first
- Teams doing a schema review who need a shared checklist of recurring, avoidable mistakes to check against
Tags
Colophon
- Publisher
- O'Reilly Japan
- ISBN
- 978-4814400744
- Published
- Jul 2025
- List price
- ¥4,290incl. taxMay differ from the actual selling price on Amazon
Get this book
* The link above is an advertisement via Amazon Associates.Related Books
Prerequisites
- Recommended
Tatsujin ni Manabu DB Sekkei Tettei Shinansho, 2nd Edition (A Thorough Guide to DB Design, Learned from an Expert)
Mick
Reason: After learning the correct design procedure, the next step is learning what not to do from cautionary examples. Bill Karwin's 'SQL Antipatterns' systematizes classic failures—missing foreign keys (Keyless Entry), EAV, comma-separated lists—reinforcing from the flip side why enforcing integrity with constraints matters.
- Recommended
Database Design for Mere Mortals, 4th Edition
25th Anniversary Edition
Michael J. Hernandez
Reason: Database Design for Mere Mortals teaches a sequence for settling keys, field specifications, relationships and business rules, and spends one late chapter on bad design. With that sequence in hand, many of the schema-design antipatterns in SQL Antipatterns can be read as what happens when one of those steps is skipped or misapplied.
- Related
Riron kara Manabu Database Jissen Nyumon (Learning Databases from Theory)
Efficient SQL through the Relational Model
Mikiya Okuno
Reason: Understanding the relational model and normalization theory lets you read each failure in Karwin's 'SQL Antipatterns' through the lens of 'which theoretical principle it violates'. Knowing the theory lets you judge why an anti-pattern is bad from first principles, turning it into transferable knowledge rather than memorization.
Next Books
- Recommended
Shippai kara Manabu RDB no Tadashii Arukikata (The Right Way to Work with RDBs, Learned from Failure)
Taketomo Sone
Reason: Where Karwin's 'SQL Antipatterns' addresses failures at the logical-design and SQL level, this Japanese book addresses RDB pitfalls that surface in production operation. Extending from design-time anti-patterns to operation-time ones gives a full panorama of failure patterns from design through operation.
- Related
Refactoring Databases
Evolutionary Database Design
Scott W. Ambler, Pramod J. Sadalage
Reason: Once Karwin's 'SQL Antipatterns' lets you spot bad designs already baked in, you next need a safe way to fix them. 'Refactoring Databases' offers a catalog of patterns for incrementally improving a schema while preserving production data, joining the discovery of anti-patterns to their remediation end to end.