I recently returned from a trip to Germany and had a chance to read The Art of SQL, by Stephane Faroult, while on my travels. I picked this book up a while back but ran out of time to read it. I am very glad that I took the time to read the book, and I consider it to be one of the greatest SQL resources I have stumbled upon. This book will remain on my shelf, and I will be going back to it for references for a long time.
Stephane starts from the basics of normal forms and goes onto deep topics such as tree hierarchies. The book does not cover syntax for queries, but instead helps you think about the queries you are righting. For those who have used SQL in the past, Stephane helps better explain how you can use relational theory to improve the speed of your queries. He talks constantly on how you can help the query optimizer and what problems you can cause for the optimizer if you choose to lay your queries out in a certain way.
The book covers many non academic problems that you run into with SQL, and gives you many patterns you can follow to help improve your SQL. Stephane will often show a common query someone would write and then go into detail on what is wrong the query. He then gives alternatives and reasons why the new query would be better. This anti-pattern/pattern approach is very handy because the reader is able to pick up on these patterns and apply them in many different situations. Stephane often gives more than one way to write the query because the speed of the query is not always dependent on how the tables are laid out, but on other criteria such as the amount of data, the indexes, and the filters used.
The only problem I have with the book is that it caters to Oracle, and does not always tell if you the syntax used will work in other DBMS’s. Most of the syntax is very generic and can be applied to almost any relation database.
I would recommend this book for anyone who is working with large amounts of data or just trying to write more efficient SQL. This book will help you think through your queries before you write them and help you become a proficient database user. The chapter on the different way to setup and use hierarchical data is worth the price of the book itself. The Art of SQL is a great book for anyone trying to deal with data in the real-world.