| | |  | Software Engineering | Home » » » SQL and Relational Theory: How to Write Accurate SQL Code | | | | | | | Description: | | Understanding SQL's underlying theory is the best way to guarantee that your SQL code is correct and your database schema is robust and maintainable. On the other hand, if you're not well versed in the theory, you can fall into several traps. In SQL and Relational Theory, author C.J. Date demonstrates how you can apply relational theory directly to your use of SQL. With numerous examples and clear explanations of the reasoning behind them, you'll learn how to deal with common SQL dilemmas, such as: - Should database access granted be through views instead of base tables?
- Nulls in your database are causing you to get wrong answers. Why? What can you do about it?
- Could you write an SQL query to find employees who have never been in the same department for more than six months at a time?
- SQL supports "quantified comparisons," but they're better avoided. Why? How do you avoid them?
- Constraints are crucially important, but most SQL products don't support them properly. What can you do to resolve this situation?
Database theory and practice have evolved since Edgar Codd originally defined the relational model back in 1969. Independent of any SQL products, SQL and Relational Theory draws on decades of research to present the most up-to-date treatment of the material available anywhere. Anyone with a modest to advanced background in SQL will benefit from the many insights in this book.
| | | Product Details: | | | Author:
| C.J. Date | | Paperback:
| 428 pages | | Publisher:
| O'Reilly Media | | Publication Date:
| January 30, 2009 | | Language:
| English | | ISBN:
| 0596523068 | | Product Length:
| 9.14 inches | | Product Width:
| 7.14 inches | | Product Height:
| 1.1 inches | | Product Weight:
| 1.69 pounds | | Package Length:
| 9.0 inches | | Package Width:
| 7.0 inches | | Package Height:
| 1.1 inches | | Package Weight:
| 1.5 pounds | | Average Customer Rating:
| based on 13 reviews |
| | | | Customer Reviews: | |
Average Customer Review:
( 13 customer reviews )
Write an online review and share your thoughts with other customers.
Most Helpful Customer Reviews
27 of 27 found the following review helpful:
Mathematics and Database DesignMar 22, 2009
By John Jacobson In this book the author argues that the only database model that will endure is the relational model, because it is "rock solid" and "right." Other models such as the "hierarchic model" or the "object oriented model" or the "semistructured model" are doomed to fail because there is no consensus on what they actually represent.
The relational model of databases is based on the pioneering work of E.F. Codd, a mathematician working for IBM who published his initial seminal paper in 1969. A language to support queries in relational databases was subsequently developed, which was ultimately named SQL, and variants of that language are used to extract data from relational databases.
This book gives an excellent review of SQL; it includes many examples of SQL code. The book is written as a technical treatise and would not be an easy read for someone who isn't familiar with the use of SQL. The original description of relational databases was mathematical in nature, and this book follows in that vein, using mathematical "proofs" to illustrate the best approach to the use of SQL in relational databases. There are many exercises given at the end of each chapter, and the answers to the exercises are given at the end of the book. There is a seven page index. Appendices A & B provide a somewhat simplified, easier to read discussion of the primary goals of the book than the book chapters do, for those wishing a simplified synopsis of the main points, I'd suggest reading those appendices first.
For those who would appreciate a theoretical discussion of database design and SQL development that will "bullet proof" their code, this is an excellent book. For those who'd like a more nuanced discussion of why there should only be one instance of any data set in their tables, this book provides the answers. But for the mathematically challenged, it may be tough going.
16 of 16 found the following review helpful:
My mind was blown, my head has grown, my SQL has entered the zoneJun 23, 2009
By M. Helmke I have spent the last three or four weeks struggling through this book. Never content to know only the "how" of something, I wanted to learn some of the "why" behind SQL databases. This book covers that in depth, with a steep learning curve for someone like me who has a bit of experience using SQL in various applications, but who has never formally studied it. That is not a bad thing.
First, a bit of background. The author, C. J. Date, is well known in the field for his classic textbook An Introduction to Database Systems, which has gone through at least eight editions. He began working on databases in 1970 at IBM and worked with the inventor of the relational theory of database design, E. F. Codd. There is no doubt that this is a man who knows what he is talking about.
What this book sets out to do, in about 400 pages, is describe and define the relational model in greater depth and compare how SQL is currently used in many database applications like Oracle and MySQL to the theoretical ideal. As he does this, Date points out several inconsistencies with the SQL adaptation of the relational model and makes suggestions for how to adjust common usage to more closely conform to the ideal while acknowledging that at times perfect syncronization will be impossible using SQL. He also gives numerous examples of how it could be done in Tutorial D, which is an interesting study in itself.
I submit that this book is ideal for theorists, for highly qualified and experienced database administrators who want to learn at the feet of a sometimes emphatic and slightly dogmatic master who has been instrumental in the creation and spread of the relational database idea, but whose theory has not been perfectly implemented. If you merely want to know how to work within current implementation constraints without the larger picture, skip this book. If you want some fascinating, and sometimes difficult to grasp background and theory that will likely make you a better database wizard, this book is likely to help you get there.
Here are some highlights, sample questions and topics discussed in the book:
* What are the differences between the relational model and the various product implementations available today and in the past? * Should a relational database allow duplicate entries? * Why are null values a bad idea? * What do relational expressions mean? * Why must database constraint checking be immediate, at least in theory, and why is it often deferred in practice?
Seriously, that is just the beginning. There are excellent examples of SQL code throughout the book, great discussions of the mathematics behind the genesis of relational theory, and more. Beware, though, you may have to work to understand it, but it will be worthwhile for those who do.
16 of 17 found the following review helpful:
The "Code Complete" of SQL BooksMar 16, 2009
By Scott Gowell
"Software Engineer / Web Developer"
C. J. Date has just released what I would say is the "Code Complete" manual for SQL. Not for the layman, this work explains [in intricate detail] the whys and wherefores of SQL, and how to over its many idiosyncrasies. From Keys and Constraints, to using joins, to all the types of normalization, this is a great reference for everyone.
If you read this book, please follow the author's instructions and don't skip over sections because of some familiarity. The detail in which he delves into even "simple" functionality in SQL are useful to see the big picture.
5 of 5 found the following review helpful:
Thick & dry but worth the readSep 13, 2010
By Dustin Davis
"Programmers Unlimited"
To start, this book is about theory and is not for anyone looking for a specific vendor implementation. Just trying to get through the first few chapter is tough because it's (just as the rest of the book) very dry and full of theory. There isn't much practicality in this book that you can apply to the real world but it does give you a way to think about what is going on behind the SQL scenes - or does it? Since each vendor has their own interpretations and implementations, I'm not so sure how this book can help structure better SQL statements in practice.
Since this book is nothing more than a history lesson with insightful explanations and examples, I would only recommend it for the academics. The book itself is not all bad however; I enjoyed chapter 4, "No duplicates, no nulls". The truth tables presented really give an idea of what potential bugs you might run into while dealing with comparisons.
To sum it up, this might as well be a textbook.
5 of 5 found the following review helpful:
Back to school treatise on what's behind the SQLApr 08, 2010
By Sergey Malgin First, disclaimer: this book is not for everyone. If you are beginner in database programming and SQL, there are plenty of other books to read. This book is more for seasoned software developers with years of practice in the field, who, like me, never really worked on database level before. There are some facts left forgotten since university years that can really make the difference on how do you see your task. Quoting from the book - 'Logical difference is a big difference'. If you want to refresh your knowledge of the theory behind the SQL, this book is for you. Author covers surprising amount of area in just a 400-page book (this count includes answers to all exercises, by the way). Author starts with basics - types, domains, tuples and relations - and immediately shows how these abstracts relate to their SQL counterparts. After you learned why nulls are bad (but sometimes necessary) and why you shouldn't use row ids in your SQL code, we gradually get to the power of formal logic behind relational algebra - and again, there's a comparison on how it looks like in SQL.
What I really liked in author's style is that he is not afraid to repeat important things until they really settle in your head. For eternally multitasking people this is a huge bonus.
The culmination of the book is the chapter 'Using logic to formulate SQL expressions'. While short, this chapter is really important and I recommend reading it several times and doing all included exercises. Again, it's not about coding, it's about proper thinking. If you know strength and weaknesses of SQL compared to relational theory, you can apply you skills more effectively.
And the last dish is an appendix B, 'Database design theory'. If you forgot why the table(s) should be normalized (and HOW they should be normalized), this is a good text to refresh your knowledge.
As I told earlier, this book is not for everyone. You should already know SQL (not all of it, but at least the basics) and have some database experience behind you. Remember, designing bad database is frustratingly easy. Read this book, get better.
See all 13 customer reviews on Amazon.com
| | | * Estimated shipping rate for US 48 states. Final rate calculated at checkout. |