Appendix B. The Quotient: An Additional Operation of the Relational Algebra

The quotient of two tables is not used often, but has a very specific use. It arises when we wish to select those rows of a table that are sufficient to provide all possible values in certain columns. As an example, imagine a business that makes furniture. The database for this business has a table on the types of wood that they use, as well as on suppliers of wood and which types they supply. Examples are shown in Table B-1 and Table B-2 (of course, these tables would include more columns, but this is just to illustrate the point).

Table B-1. WOOD

Type

Mahogany

Red oak

Poplar

Walnut

Table B-2. SUPPLIER/TYPE

Sname

Type

Jones Wood Supply

mahogany

Austin Hardwoods

red oak

Orange Coast

mahogany

Jones Wood Supply

poplar

West Lumber

poplar

Jones Wood Supply

walnut

Austin Hardwoods

walnut

Jones Wood Supply

red oak

Orange Coast

walnut

West Lumber

red oak

Orange Coast

poplar

Orange Coast

red oak

Fred’s Woods

walnut

Note that there are four types of wood. Suppose we want to know which suppliers supply all four types—a reasonable question. The answer, which is shown in Table B-3 is called the quotient of the table SUPPLIERS/TYPE by WOOD, written SUPPLIER/TYPE ÷ WOOD.

Table B-3. SUPPLIER/TYPE WOOD

Sname

Jones Wood Supply

Orange Coast

As you can see, the quotient can certainly come up in real-life situations. The reason for defining a specific operation for this purpose is that expressing the quotient in terms of the other relations is a bit complex. Let’s do it to illustrate the virtue of the quotient.

The idea is actually relatively simple. We first get a table, called T, containing all rows that are not in the SUPPLIER/TYPE table. This new table will involve only those suppliers who have not supplied all types of wood. (If a supplier supplies all four types of wood, then there will be four rows in the SUPPLIER/TYPE table and therefore no rows in T.) Then we subtract this from a table containing all (participating) suppliers. Here is the step-by-step procedure.

Step 1

Form the table:

R = [projSName(SUPPLIER/TYPE) WOOD] - SUPPLIER/TYPE

Table B-4, the table R, contains all rows of the form (SName,Type) that are not in the SUPPLIER/TYPE table. Put another way, it is the set of “missing possibilities” in the Cartesian product (which is the set of all possibilities).

Table B-4. R

Sname

Type

Austin Hardwoods

poplar

West Lumber

walnut

Austin Hardwoods

mahogany

West Lumber

mahogany

Fred’s Woods

walnut

Step 2

Form the table:

projSName(R)

That is, project the table R onto the SName column, giving the SUPPLIERS that do not supply all types of wood, as shown in Table B-5.

Table B-5. projSName(R)

SName

Austin Hardwoods

West Lumber

Fred’s Woods

Step 3

Finally, form the table:

projSName(SUPPLIERS/TYPE) - projSName (R)

That is, subtract the table in Step 2 from the first column of the SUPPLIERS/TYPE table. This gives the suppliers that supply all four types of wood, as Table B-6 illustrates.

Table B-6. SUPPLIER/TYPE ÷ WOOD

SName

Jones Wood Supply

Orange Coast

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.107.181