5 minute book review: The Art of SQL

I have a simple algorithm for picking books: I buy until my wife tells me I have to sleep outside I try to read books that take a practical and interesting approach.

For technical books about databases the quality is really uneven. You have your query tuning books which are good overviews of how DBMS X query engine works, some examples of the different selectors, and some practical advice followed by some vendor copy about how the next version of DBMS X will solve everything including your inability to feel as if you deserve true love. Other books are theoretical modeling exercises that walk you through how to build an order system so that it makes a college professor stroke his beard and half-smile.

The Art of SQL is a combination query tuning/performance book, modeling book, and practical advice book. Think of it as Design Patterns for SQL – it could have easily been called the title of one of its chapters: “The Nine Situations” as it goes over common situations you will face in getting a relational database to run quickly. The book is written in the “Art of War” style and uses (surprisingly effective) war metaphors throughout the chapters – it calls performance monitoring tools the “employment of spies” and begins each chapter with a war quote that also applies to database management (In a chapter on planning: “It is the first step that reveals genius in all wars”)

This book isn’t vendor specific but still has practical examples including some advice on how to handle SQL generated by code (with a realistic PHP/MySQL example – name another database book with non-ironic PHP in it). Reading through this book was sort of painful for me since it talked about things that you should avoid which I did not in any way avoid in the past and offered practical advice on dealing with things that I had run around like a man in a padded room before discovering.  Just look at these chapters:

  • Representing Trees in a SQL Database
  • Distributed Systems
  • To Be or Not to Be, or to Be Null
  • The Difficulties of Historical Data
  • Considering Indexes as Data Repositories
  • Holy Simplicity

I’d recommend The Art of SQL as a good “second book” for developers looking to understand databases, why DBAs don’t like NULLs, why linked servers should be avoided, why your code to generate SQL makes DBAs beards turn white overnight, and how to best plan out your database structure.