Wednesday, May 13, 2009

SQL and Relational Theory: How to Write Accurate SQL Code

When I first got this book I was very excited; the author, C.J. Date is one of those names that you hear tossed around with Codd. I was hoping that this book would be a good refresher on basic SQL theorems and relational design, and while I was not disappointed, I was a bit overwhelmed by the third chapter. Having recently seen the latest incarnation of Star Trek, I thought a science-fiction metaphor might be appropriate.

Reading this book made me realize that I’m an engineer; I am Scotty. I know how my particular environment works, I know when “I’m giving her all she’s got”, and I know how to tweak the system to keep it afloat when pressed with stressful situations. SQL Server is a wonderful platform, but like all database systems, it’s got its own peculiar quirks. Like all good engineers, you can learn to make the best of those quirks, but it doesn’t mean you understand how the engine is supposed to work.

Date is definitely Spock; beyond the logical comparisons (pardon the pun), Date’s focus is on the theory of how the relational model is supposed to work, not necessarily how SQL is implemented in the various database platforms. Very early on, he distinguishes between the relational model and SQL, and it became increasingly clear as I read this book that SQL <> relational model. Date tries his best to explain a very complex subject in a very thorough method, but I’m afraid that I’m not one of his best students.

The math involved in the relational model is very complex, and at times, I found myself frustrated with a passage because I knew how to do something in SQL, but had no clue as to what Date was saying in a relational language. That’s both sad and liberating in a way; I walked away from this book knowing first that I’m comfortable being an engineer, and second that I need to re-read this material occasionally. Date is like broccoli; he’ll never be my favorite author, but I know that what he’s writing is good for me.

4 out of 5 stars.

No comments:

Post a Comment