Chapter 11. SQL Operators I
You know my methods. Apply them.
—Arthur Conan Doyle: The Sign of Four (1890)
Now we can begin to examine the question of how, or to what extent, SQL supports the various operators of the relational algebra. For obvious reasons, the structure of this chapter deliberately parallels that of Chapter 4 in Part I of the book. First, however, let me remind you that:
SQL tables can contain duplicate rows—so you should take steps to prohibit them wherever you can (at least if you want the tables in question to be amenable to relational processing).
SQL tables have a left to right ordering to their attributes—but try not to write code that relies on that ordering, because such code is (by definition) not relational.
SQL tables can contain nulls—but don’t let them!
Note: The book SQL and Relational Theory describes a discipline it refers to as “using SQL relationally.” The idea is that if you abide by the recommendations in that book, then you can behave almost as if SQL truly were relational, and you can enjoy the benefits of working with what is, in effect, a truly relational system (or close to one, at any rate). And it probably goes without saying that the SQL discussions in the present book do abide by those recommendations, pretty much. As I’ve said before, I’m not trying to cover the whole of SQL here, I’m just trying to cover those aspects that are at least somewhat relational.
Restrict
Most of the time I plan to use the same examples in this chapter as I did in ...
Get Relational Theory for Computer Professionals now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.