SQL Antipatterns, Volume 1 (Pragmatic Bookshelf)

PragmaticBookshelf
SQL Antipatterns is a short-cut to wisdom, showing you how to avoid "easy" solutions that don't work, and be a better database developer in any language.

Bill Karwin (@billkarwin)

edited by Jacquelyn Carter @jkcarter

SQL is the ubiquitous language for software developers working with structured data. Most developers who rely on SQL are experts in their favorite language (such as Java, Python, or Go), but they’re not experts in SQL. They often depend on antipatterns—solutions that look right but become increasingly painful to work with as you uncover their hidden costs. Learn to identify and avoid many of these common blunders. Refactor an inherited nightmare into a data model that really works. Updated for the current versions of MySQL and Python, this new edition adds a dozen brand new mini antipatterns for quick wins.

No matter which platform, framework, or language you use, the database is the foundation of your application, and the SQL database language is the standard for working with it. Antipatterns are solutions that look simple at the surface, but soon mire you down with needless work. Learn to identify these traps, and craft better solutions for the often-asked questions in this book. Avoid the mistakes that lead to poor performance and quality, and master the principles that make SQL a powerful and flexible tool for handling data and logic.

Dive deep into SQL and database design, and learn to recognize the most common missteps made by software developers in database modelling, SQL query logic, and code design of data-driven applications. See practical examples of misconceptions about SQL that can lure software projects astray. Find the greatest value in each group of data. Understand why an intersection table may be your new best friend. Store passwords securely and don’t reinvent the wheel. Handle NULL values like a pro. Defend your web applications against the security weakness of SQL injection.

Use SQL the right way—it can save you from headaches and needless work, and let your application really shine!


Bill Karwin has been a software engineer for over thirty years, developing and supporting applications, libraries, and servers, and consulting for leading technology companies. 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.


Don’t forget you can get 35% off with your Devtalk discount! Just use the coupon code “devtalk.com" at checkout :+1:

Latest Threads About This Book Top

blabla_bingo
@billkarwin ON page 213, the generate-update.sql code uses a single SELECT query to generate multiple UPDATE statements, which have to b...
New
blabla_bingo
@billkarwin On page 186,both the rand-limit-offset.py and rand-row-number.py code uses round function, which will possibly get the total...
New
blabla_bingo
@billkarwin On page 176 , the derived-table-no-duplicates.sql code would not get the correct result if multiple product_id with the same...
New
New
doblebis
Found in first printing (P 1.0). The text reads “certain verions” instead of “certain versions”.
New
New
New
crash
REPLACE INTO PasswordResetRequest (account_id, token, account_id, expiration) VALUES (123, @token, CURRENT_TIMESTAMP + INTERVAL 1 HOUR);
New
crash
@billkarwin You say that the DB is in the 5th normal form if it does not have compound PK. But in the solution tables you still have co...
New
crash
@billkarwin You say partitioning by date_reported but in the example there is a partition by hash ( bug_id ).
New

Most Active This Week Top

Most Active This Month Top

Most Active This Year Top

New

Most Active Last Three Years Top

PragmaticBookshelf
SQL Antipatterns is a short-cut to wisdom, showing you how to avoid "easy" solutions that don't work, and be a better database developer ...
New
Ted
I’m enjoying the book and I’m happy to see that the discussion of GROUP BY in chapter 15 also includes a callout box titled “GROUP BY and...
New
crash
@billkarwin You say partitioning by date_reported but in the example there is a partition by hash ( bug_id ).
New
Ted
Hi Bill. I’m glad to see you cover a lot of important topics about dealing with passwords in Chapter 20, “Readable Passwords”. However,...
New
billkarwin
PlanetScale Vitess 14 is a great technology to supporting sharded architecture with MySQL, but it has does not support stored procedures ...
New
crash
REPLACE INTO PasswordResetRequest (account_id, token, account_id, expiration) VALUES (123, @token, CURRENT_TIMESTAMP + INTERVAL 1 HOUR);
New
New
New
doblebis
Found in first printing (P 1.0). The text reads “certain verions” instead of “certain versions”.
New
crash
@billkarwin You say that the DB is in the 5th normal form if it does not have compound PK. But in the solution tables you still have co...
New
blabla_bingo
@billkarwin ON page 213, the generate-update.sql code uses a single SELECT query to generate multiple UPDATE statements, which have to b...
New
blabla_bingo
@billkarwin On page 176 , the derived-table-no-duplicates.sql code would not get the correct result if multiple product_id with the same...
New
blabla_bingo
@billkarwin On page 186,both the rand-limit-offset.py and rand-row-number.py code uses round function, which will possibly get the total...
New

Most Active Over Three Years Top

Get money off!

The Pragmatic Bookshelf

35% off any eBook

Simply use coupon code "devtalk.com" at checkout. See full details here.