Prerequisites
I assume youre a database practitioner and therefore reasonably familiar with SQL already. To be specific, I assume you have a working knowledge of either the SQL standard or (perhaps more likely in practice) at least one SQL product. However, I dont assume you have a deep knowledge of relational theory as such (though I do hope you understand that the relational model is a good thing in general, and adherence to it wherever possible is a desirable goal). In order to avoid misunderstandings, therefore, Ill be describing various features of the relational model in detail, as well as showing how to use SQL to conform to those features. But what I wont do is attempt to justify all of those features; rather, Ill assume youre sufficiently experienced in database matters to understand why, e.g., the notion of a key makes sense, or why you sometimes need to do a join, or why many to many relationships need to be supported. (If I were to include such justifications, this would be a very different bookquite apart from anything else, it would be much bigger than it already isand in any case, that book has already been written.)
Ive said I expect you to be reasonably familiar with SQL. However, I should add that Ill be explaining certain aspects of SQL in detail anywayespecially aspects that might be encountered less frequently in practice. (The SQL notion of possibly nondeterministic expressions is a case in point here. See .)
Database in Depth
This book is based on, and intended to replace, an earlier one with the title Database in Depth: Relational Theory for Practitioners (OReilly Media Inc., 2005). My aim in that earlier book was as follows (this is a quote from the preface):
After many years working in the database community in various capacities, Ive come to realize theres a real need for a book for practitioners (not novices) that explains the basic principles of relational theory in a way not tainted by the quirks and peculiarities of existing products, commercial practice, or the SQL standard. I wrote this book to fill that need. My intended audience is thus experienced database practitioners who are honest enough to admit they dont understand the theory underlying their own field as well as they might, or should. That theory is, of course, the relational modeland while its true that the fundamental ideas of that theory are all quite simple, its also true that theyre widely misrepresented, or underappreciated, or both. Often, in fact, they dont seem to be understood at all. For example, here are a few relational questions ... How many of them can you answer?[]
What exactly is first normal form?
Whats the connection between relations and predicates?
Whats semantic optimization?
Whats an image relation?
Why is semidifference important?
Why doesnt deferred integrity checking make sense?
Whats a relation variable?
Whats prenex normal form?
Can a relation have an attribute whose values are relations?
Is SQL relationally complete?
Why is The Information Principle important?
How does XML fit with the relational model?
This book provides answers to these and many related questions. Overall, its meant to help database practitioners understand relational theory in depth and make good use of that understanding in their professional day-to-day activities.
As the final sentence in this extract indicates, it was my hope that readers of that book would be able to apply its ideas for themselves, without further assistance from me as it were. But Ive since come to realize that, contrary to popular opinion, SQL is such a difficult language that it can be far from obvious how to use it without violating relational principles. I therefore decided to expand the original book to include explicit, concrete advice on exactly that issue (how to use SQL relationally, I mean). So my aim in the present book is still the same as beforeI want to help database practitioners understand relational theory in depth and make good use of that understanding in their professional activitiesbut Ive tried to make the material a little easier to digest, perhaps, and certainly easier to apply. In other words, Ive included a great deal of SQL-specific material (and its this fact, more than anything else, that accounts for the increase in size over the previous book).