Databases Reference
In-Depth Information
Chapter 11
D i f f e r e n c e V i e w s
I'll teach you differences: away, away!
—William Shakespeare: King Lear (1605?)
In this chapter I'll consider the question of updating through the relational difference operator
(MINUS, in Tutorial D ). Now, I'm sure you won't be surprised to learn the chapter is fairly
similar in structure to its immediate predecessors, on intersection and union. However, it also
differs—how appropriate!—in certain important respects, as you'll quickly see. To elaborate
briefly: Suppose we're given two relvars A and B . Clearly, if A = B , the difference A MINUS B
and the difference B MINUS A are both empty, so that case isn't very interesting. Also, if A and
B are disjoint, then A MINUS B is equal to A and B MINUS A is equal to B , so that case isn't
very interesting either. So the interesting case is the one in which A and B aren't equal but do
overlap. As in Chapter 9, therefore (on intersection), I'll consider two examples, one in which
the overlap is explicit and one in which it's merely implicit. For reasons that will become clear
later, however, this time I want to consider the implicit case first.
EXAMPLE 1: IMPLICIT OVERLAP
My first example is based once again on the “parts on sale” vs. “parts in stock” example from
Chapters 9 and 10. Once again, then, we have two relvars PL and PK, each with just a single
attribute PNO—relvar PL gives part numbers for parts on sale, and relvar PK gives part numbers
for parts in stock. Now, there are obviously two possible differences we might consider; for
definiteness, let's focus on the difference PL MINUS PK (DLK, say), which gives part numbers
for parts that are on sale but not in stock. Thus, the predicates are as follows:
PL: Part PNO is on sale.
PK: Part PNO is in stock.
DLK: Part PNO is on sale and not in stock.
Sample values are shown in Fig. 11.1.
 
Search WWH ::




Custom Search