SQL Antipatterns: Avoiding the Pitfalls of Database Progr... and over 2 million other books are available for Amazon Kindle . Learn more

Sign in to turn on 1-Click ordering.
Trade in Yours
For a £3.93 Gift Card
Trade in
More Buying Choices
Have one to sell? Sell yours here
Sorry, this item is not available in
Image not available for
Image not available

Start reading SQL Antipatterns on your Kindle in under a minute.

Don't have a Kindle? Get your Kindle here, or download a FREE Kindle Reading App.

SQL Antipatterns: Avoiding the Pitfalls of Database Programming (Pragmatic Programmers) [Paperback]

Bill Karwin
4.3 out of 5 stars  See all reviews (3 customer reviews)
RRP: £22.50
Price: £22.40 & FREE Delivery in the UK. Details
You Save: £0.10
o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
Only 5 left in stock (more on the way).
Dispatched from and sold by Amazon. Gift-wrap available.
Want it tomorrow, 21 Sep.? Choose Express delivery at checkout. Details


Amazon Price New from Used from
Kindle Edition £18.62  
Paperback £22.40  
Trade In this Item for up to £3.93
Trade in SQL Antipatterns: Avoiding the Pitfalls of Database Programming (Pragmatic Programmers) for an Amazon Gift Card of up to £3.93, which you can then spend on millions of items across the site. Trade-in values may vary (terms apply). Learn more

Book Description

5 July 2010 1934356557 978-1934356555 1

Bill Karwin has helped thousands of people write better SQL and build stronger relational databases. Now he's sharing his collection of antipatterns--the most common errors he's identified in those thousands of requests for help.

Most developers aren't SQL experts, and most of the SQL that gets used is inefficient, hard to maintain, and sometimes just plain wrong. This book shows you all the common mistakes, and then leads you through the best fixes. What's more, it shows you what's behind these fixes, so you'll learn a lot about relational databases along the way.

Each chapter in this book helps you identify, explain, and correct a unique and dangerous antipattern. The four parts of the book group the anti​patterns in terms of logical database design, physical database design, queries, and application development.

The chances are good that your application's database layer already contains problems such as Index Shotgun, Keyless Entry, Fear of the Unknown, and Spaghetti Query. This book will help you and your team find them. Even better, it will also show you how to fix them, and how to avoid these and other problems in the future.

SQL Antipatterns gives you a rare glimpse into an SQL expert's playbook. Now you can stamp out these common database errors once and for all.

Whatever platform or programming language you use, whether you're a junior programmer or a Ph.D., SQL Antipatterns will show you how to design and build databases, how to write better database queries, and how to integrate SQL programming with your application like an expert. You'll also learn the best and most current technology for full-text search, how to design code that is resistant to SQL injection attacks, and other techniques for success.

Frequently Bought Together

SQL Antipatterns: Avoiding the Pitfalls of Database Programming (Pragmatic Programmers) + Joe Celko's SQL for Smarties: Advanced SQL Programming (The Morgan Kaufmann Series in Data Management Systems)
Price For Both: £51.97

Buy the selected items together

Product details

  • Paperback: 328 pages
  • Publisher: Pragmatic Bookshelf; 1 edition (5 July 2010)
  • Language: English
  • ISBN-10: 1934356557
  • ISBN-13: 978-1934356555
  • Product Dimensions: 22.9 x 18.8 x 2.5 cm
  • Average Customer Review: 4.3 out of 5 stars  See all reviews (3 customer reviews)
  • Amazon Bestsellers Rank: 92,901 in Books (See Top 100 in Books)

More About the Author

Discover books, learn about writers, and more.

Product Description


""This book is obviously the product of many years of practical experience with SQL databases. Each topic is covered in great depth, and the attention to detail in the book was beyond my expectations. Although it's not a beginner's book, any developer with a reasonable amount of SQL experience should find it to be a valuable reference and would be hard-pressed not to learn something new.""--Mike Naberezny, Partner at Maintainable Software; Coauthor of "Rails for PHP Developers"""Bill has written an engaging, useful, important, and unique book. Software developers will certainly benefit from reading the antipatterns and solutions described here. I immediately applied techniques from this book and improved my applications. Fantastic work!""--Frederic Daoud, Author of "Stripes: ...And Java Web Development Is Fun Again" and "Getting Started with Apache Click"

About the Author

Bill Karwin has been a software engineer for over twenty years, developing and supporting applications, libraries, and servers such as Zend Framework for PHP 5, the InterBase relational database, and the Enhydra Java application server. Throughout his career, Bill has shared his knowledge to help other programmers achieve success and productivity. Bill has answered thousands of questions, giving him a unique perspective on SQL mistakes that most commonly cause problems.

Customer Reviews

3 star
2 star
1 star
4.3 out of 5 stars
4.3 out of 5 stars
Most Helpful Customer Reviews
8 of 8 people found the following review helpful
4.0 out of 5 stars Excellent book 9 Aug 2010
Enjoyed this. It's relatively short but the content is concise and lucid. Many of the anti-patterns are relatively basic for developers with more than a few years of experience, but it's a highly worthwhile read nonetheless. Along with informative explanations of good practice in developing database-backed applications, there are some really useful tips and insights for solving database problems.

As a team leader in a dev shop, this is the kind of book that I want all my team to read. I'm going to get a few more copies for the company and add it the required reading list along the Code Complete and Clean Code.

Definitely recommended.
Comment | 
Was this review helpful to you?
2 of 2 people found the following review helpful
4.0 out of 5 stars Worth a read 10 April 2011
As other reviews on here have said... if you have a few years of DBA/Dev experience then you really shouldn't be getting caught out by these anti-patterns. Having said that, I did enjoy reading it. Also, if you are spotting the mistakes in the patterns early on then it's a good confirmation that you know what you are doing!
I gave it 4 stars because I enjoyed the read, I would have given it 5 if I had learned more new stuff. If you are new to DBA/Dev then it would probably be a 5 star book for you.
Comment | 
Was this review helpful to you?
5.0 out of 5 stars Tells you why your databases suck 13 Feb 2013
Format:Paperback|Verified Purchase
Anyone who has had problems with databases should read this book - it explains many of the traps that the unsuspecting database designer could fall into and how to avoid them. More importantly, the problems with each anti-pattern are explained, along with examples, and then a better way of solving the same problem is given.
Comment | 
Was this review helpful to you?
Most Helpful Customer Reviews on Amazon.com (beta)
Amazon.com: 4.6 out of 5 stars  34 reviews
36 of 37 people found the following review helpful
5.0 out of 5 stars A Very Useful and Entertaining Book 30 July 2010
By Data Guy - Published on Amazon.com
I have a vast collection of SQL books. If it was published in the last 10 or so years, I probably have a copy. Some of them are very good, but there are quite a few similar-looking SQL books, with a similar purpose and a similar look-and-feel. So it takes some doing for a new SQL book to rise above the chaff... but SQL Antipatterns by Bill Karwin manages to do so.

This is not yet another book on SQL syntax or style. SQL Antipatterns is something altogether unique. The book is designed to point out the common things that SQL developers do, that they shouldn't be doing. Each chapter assists the reader in identifying, explaining, and correcting dangerous practices - or antipatterns.

If you take the time to read through this thoughtful book I'm sure you'll recognize some of the antipatterns. Some of you will have done them yourself, whereas others of you probably will have worked to undo some of them.

OK, many of you are still likely to be wondering what exactly is an antipattern is, right? Well, I'll give you one of the examples from Karwin's book -- Jaywalking. This is the first antipattern covered in the book and it is one of my favorites (err, I mean least favorites, I think). Jaywalking is when developers store comma-separated lists in a database column instead of redesigning the database structure in a normalized fashion. Karwin calls this jaywalking because both this practice and actual jaywalking on a street are acts of "avoiding an intersection." Funny...

Each antipatterns is described along with a clear explanation as to why it is a bad practice and advice on building a better solution. Other antipatterns covered in the book are named almost as intriguingly, such as Pseudokey Neat-Freak, Keyless Entry, Magic Beans, See No Evil, and Metadata Tribbles.

The book is not just for unlearning what you shouldn't be doing, it can also be helpful for learning new and improved development techniques. Reading SQL Antipatterns can help you to learn about current technology for full-text search, how to design code that is resistant to SQL injection attacks, and many other techniques for success.

The book is very well-organized into four parts grouping the antipatterns into the following categories: logical database design, physical database design, queries, and application development.

SQL Antipatterns should become a useful tool for DBAs and database programmers to help them create well-designed databases and applications... and to help us eliminate these common errors from our database implementations.
30 of 31 people found the following review helpful
5.0 out of 5 stars An excellent guide to Database Design tradeoffs 9 July 2010
By HC Mitchell - Published on Amazon.com
I recently got a new job and inherited a vast collection of SQL queries to maintain. Reading Karwin's book has been a tremendous help! Each chapter considers a particular design issue ("How can I store more than one value in a field?") and shows the most common, flawed method (the "antipattern"). He carefully explains the disadvantages, then usually shows several other ways to accomplish the same goal.

One of the things I like best about the book is that the analysis isn't black and white. Every methods has advantages and disadvantages, which Karwin carefully unpacks. He also reviews and clarifies relational theory as he goes: his discussion of "Null" is a masterpiece. In general, he favors solutions that don't subvert the basic principles of relational database theory.

This would not be a good book to try to learn SQL or Database theory from, but if you are just starting to get some real-world experience it is a Godsend. Highly Recommended.
7 of 7 people found the following review helpful
5.0 out of 5 stars Deals with problems related to both database's design and application developing 24 Aug 2010
By Foti Massimo - Published on Amazon.com
I must admit that there was barely anything new to me in the book, but I have been in the field for quite a few years, dealing with many projects, so I had the "privilege" of seeing many horror stories. Still, I feel the book is valuable even for seasoned veterans. The main benefit is that the author organized and grouped the anti-patterns, each one is analyzed very well and contains some wise, unbiased suggestions. Each chapter stands on its own and can be read stand-alone.
The book is worth an extra star because it deals with problems related to both database's design and application developing; most book out there either cover one or the other.
This should be a mandatory reading for beginner DBAs and application developers, veterans may like it too, since it can help refreshing some concepts and can be used as a reference too.
9 of 10 people found the following review helpful
5.0 out of 5 stars Great Book for Creating Effecient SQL 3 Aug 2010
By Frank Stepanski - Published on Amazon.com
This book is very unique as far as database design and writing SQL statements. I could be called a 'cookbook' or a 'how-to' book, but its much more than that. The word 'antipatterns' means a way of doing something that is counter-productive in some form or another. So its basically of way to NOT do something. That may seem weird, but if you are aware of ways (patterns) that are ineffective, you will try to avoid those ways and be a more effectve programmer, developer, manager, etc.

There are lots of SQL and Database design books on how to do proper SQL statements but there are very few if any on showing students on what NOT to do with SQL. Its a great way to continue to learn SQL and Database design and advance your skills.

The author does an excellent job in going through all the phases of SQL antipatterns.

1. Rounding errors
2. Phamtom files
3. Index shotgun
4. fear of the unknown
5. random selection
6. spaghetti query
7. sql injection
8. magic beans
9. see no evil
10. ambiguous groups

The names may sound funny, but they are very informative and definitley worth understanding to realy be and efficient database programmer.

A great book and a must buy!
8 of 9 people found the following review helpful
5.0 out of 5 stars The pitfalls of promiscuity 4 Mar 2011
By Kenneth B. Sizer II - Published on Amazon.com
"SQL Antipatterns" by Bill Karwin is a collection of 4~7 page chapters, each neatly organized into:
1) Here's something people often need to do
2) Here's the stupid solution they often come up with
3) Here's why that's a bad idea
4) Here's what you should do instead

The nice, bite-sized chapters along with the "standalone" nature of each are reminiscent of "Effective Java," another favorite.

Among other cuteness, the author refers to foreign keys that relate to multiple tables as "promiscuous"... I give extra points to anyone who can weave a little innuendo into an SQL text.
Were these reviews helpful?   Let us know
Search Customer Reviews
Only search this product's reviews

Customer Discussions

This product's forum
Discussion Replies Latest Post
No discussions yet

Ask questions, Share opinions, Gain insight
Start a new discussion
First post:
Prompts for sign-in

Search Customer Discussions
Search all Amazon discussions

Look for similar items by category