Databases Reference
In-Depth Information
being inserted into any relvar PK; the specification for Possibility 3 would be PRED (NOT
ON_SALE AND IN_STOCK), which would cause the tuple to be deleted from relvar PL and
inserted into relvar PK. And it seems reasonable to make this last specification the default, so
that if no explicit PRED specification appears at all, the delete behaves exactly as described in
Chapter 11.
MORE ON PREDICATES
One reviewer of an early version of this chapter expressed some doubt as to whether the
arguments in the last two sections were really valid. To be specific, he—the reviewer was
male—suggested it might not always be true that (for example) in the case of a view defined as A
UNION B , the user would know that the predicate was of the form pred ( A ) OR pred ( B ). And he
went on to give an example of two relvars MOTHER and FATHER, each with a single attribute
called NAME, and predicates NAME is somebody's mother and NAME is somebody's father ,
respectively, and then suggested that the predicate for MOTHER UNION FATHER might be,
not NAME is somebody's mother OR NAME is somebody's father , but simply NAME is
somebody's parent .
In response to this example, let me observe first that relvars MOTHER and FATHER are
clearly disjoint, and the union is thus a disjoint union. So the true predicate for that union isn't
quite as I gave it in the previous paragraph, but rather:
(NAME is somebody's mother OR NAME is somebody's father)
AND
NOT (NAME is somebody's mother AND NAME is somebody's father)
Thus, if a user of the union view really does know only the predicate NAME is somebody's
parent , there won't be any way for that user to specify that INSERT operations on the view must
effectively be targeted at just one of the two relvars MOTHER and FATHER. Instead, such
operations will simply fail, on a Golden Rule violation.
That being said, I think I'd also have to question the wisdom of the DBA—or whoever it is
who's responsible for informing the user of the predicate for the view—if that person decided, in
the case at hand, not to tell the user what the proper predicate was. But you can't legislate
wisdom, I suppose.
Be that as it may, what happens if the union view doesn't represent a disjoint union? Let's
take a concrete example (a variation on an example discussed briefly in Chapter 10). Suppose
some parts are manufactured abroad, others are manufactured domestically, and some are both.
Suppose further that we represent this situation by means of two relvars, both with a single
attribute PNO, one (PA) giving part numbers for parts manufactured abroad, the other (PD)
giving part numbers for parts manufactured domestically. Then the union of these two relvars—
 
Search WWH ::




Custom Search