Division operator in Relational Databases


Yesterday before submitting my assignment of the database, which was totally related to relational algebra queries, i got stuck in Division operator. I read the text book of Connolly “Introduction to Database System” But the formulas got me confused.

Then eventually I’ve just got a copy of THE MANGA GUIDE TO DATABASES (ISBN 978-1-59327-190-9); it is one of a series of “Manga Guides” (the others are Calculus and Statistics).  Since I consider myself a long time comic book fan, rather than a Dummy or an Idiot, I prefer these titles over their competition on the book shelf.  But beside the risk that the title poses to my personal dignity, the book is a really good introductory book.  You just have to get over the Japanese ‘database fairy’ Tico in the Kingdom of Kod.

The book has a section on basic RDBMS in which they mention Codd’s eight original operations on tables.  If you don’t remember them, they were the three classic set operators: UNION, INTERSECTION and DIFFERENCE and five relationship operators: JOIN, PROJECTION, SELECTION, CARTESIAN PRODUCT and DIVISION.  Since RDBMS is based on sets, you can see why the classic set operators are there.  What is hard to figure out is why it took so long to get INTERSECTION and DIFFERENCE into SQL.  We had JOIN, PROJECTION, SELECTION and CARTESIAN PRODUCT right away in SQL because you cannot do anything without them in an RDBMS.

The Book explains the division operator like this.

Division is the operation that extracts the rows whose column values matches those in the 2nd table, but only return the columns that don’t exist in the 2nd table. Confused?

Here is the example

and the result

I hope now at least my classmates will understand the division operator in relational model.

Though that’s not all but this is the basic understanding to begin with. After all we are only studying “Introduction to databases” not Advanced database Systems :D