Every professional programmer (and DBA) should have a library of books on SQL fundamentals. There are many SQL titles to choose from, and a lot of them are very good. But this month's column will outline four SQL books that should be on every database professional's bookshelf.
The first SQL book is SQL Performance Tuning by Peter Gulutzan and Trudy Pelzer. This fine tome provides a treasure trove of tips for improving SQL performance on all of the major database systems. It does not teach SQL syntax, but instead helps the reader to understand the differences between the most popular DBMS products, including Oracle, DB2, SQL Server, Sybase ASE, MySQL, Informix, Ingres, and even InterBase.
Throughout this book the authors present and test techniques for improving SQL performance, and grade each technique for its usefulness on each of the major DBMSs. If you deal with heterogeneous database implementations this book will be a great assistance, whether you are a programmer, consultant, DBA, or technical end user. The contents of this book can help you to decide which tuning techniques will work for which DBMS.
My next SQL book recommendation is altogether different in purpose than the first. It is SQL in a Nutshell, third edition, by Kevin Kline, Daniel Kline, and Brand Hunt. This book offers a great cross-platform syntax reference for SQL. It probably is not the easiest reference to use for finding the exact syntax for one particular DBMS; but it is absolutely the best reference for those who work with multiple DBMSs. Be sure to get the third edition, which is up-to-date and offers more depth than the previous editions.
Next up is The Art of SQL by Stephane Faroult, which is a guide to SQL written using the approach of The Art of War by Sun-Tzu. The author actually uses the exact same title chapters for The Art of SQL that Sun Tzu used in The Art of War. Amazingly enough, the tactic works.
Consider, for example, the chapter titled "Laying Plans," in which Faroult examines how to design databases for performance. As anyone who ever built database applications knows, an improperly designed database can be the biggest impediment to flawless application performance. The chapter titled "Tactical Dispositions" covers the topic of indexing and in "The Nine Situations" the author examines several classic SQL patterns and how best to approach them.
This book is not for a novice who wants to learn SQL from scratch. The authors assume the reader is conversant with SQL as they describe how to apply SQL in a practical manner. If you can't code an outer join or don't know what a nested table expression or in-line view is, then this is not the book for you.
Neither is the book a list of SQL scripts that you can pluck out and use. Instead, the book skillfully manages to explain how to properly attack the job of coding SQL to effectively and efficiently access your data.
The Art of SQL skillfully manages to explain how to properly attack the job of coding SQL to effectively and efficiently access your data. The book offers best practices that teach experienced SQL users to focus on strategy rather than specifics." You know that if Sun Tzu coded SQL, he might have written a book like The Art of SQL. But since Sun Tzu is dead, I'm glad Stephane Faroult was around to author this.
The final SQL book recommendation is the latest edition of Joe Celko's SQL for Smarties, Fourth Edition: Advanced SQL Programming. Celko was a member of the ANSI SQL standards committee for 10 years, and is highly qualified to write such a text. The latest edition of this fine book is the fourth edition, which was completely revised (in 2010) and boasts more than 800 pages of advanced SQL programming techniques. If you have any of the past editions of this book, you owe it to yourself to get the newly revised fourth edition.
This book offers tips, techniques, and guidance on writing effective, sometimes complex, SQL statements using ANSI standard SQL. It touches on topics ranging from database design and normalization to using proper data types to grouping and set operations, optimization, data scaling, and more. Every developer who codes SQL statements for a living will find something useful in SQL for Smarties!
These four books, properly used, can turn a fledgling SQL developer into an expert - and they can assist even the expert to become a better user of SQL.