Databases Reference
In-Depth Information
VAR V1 VIRTUAL ( S WHERE CITY = 'London' OR CITY = 'Paris' ) ;
VAR V2 VIRTUAL ( ( S WHERE CITY = 'London' )
UNION
( S WHERE CITY = 'Paris' ) ) ;
Now, it's intuitively obvious that these two views are semantically equivalent, even though
their definitions—more precisely, their defining expressions—are syntactically distinct. What I
mean by this observation is that (to spell the point out) it's clearly the case that at any given time,
those two expressions both denote the same relation. Thus, it's also intuitively obvious that (a) if
Q is a query on either V1 or V2, then Q is defined for the other view as well (and it produces the
same result on both), and (b) what's more, an analogous remark applies to updates also. But I
want to take a closer look at part (b) of this claim in particular.
First, then, let's think about INSERT operations. Suppose we try to insert a tuple for
supplier S9 with city London. Then:
In the case of V1, the rules for inserting through a restriction come into play (see Chapter
4), and the net effect is that the new tuple is inserted into relvar S and thus into V1 as well.
In the case of V2, the rules for inserting through a union come into play (see Chapter 10).
Since the new tuple satisfies the restriction condition for one union operand—viz., the one
denoted by the expression S WHERE CITY = 'London'—and not for the other, it's
inserted into that operand and not into the other. The rules for inserting through a
restriction then come into play again, and the net effect is that the new tuple is inserted into
relvar S and thus into V2 as well.
Second, DELETE operations. Suppose we try to delete the tuple for supplier S1. Then:
In the case of V1, the rules for deleting through a restriction come into play (see Chapter
4), and the net effect is that the specified tuple is deleted from relvar S and thus from V1 as
well.
In the case of V2, the rules for deleting through a union come into play (see Chapter 10).
Since the specified tuple appears in one union operand—viz., the one denoted by the
expression S WHERE CITY = 'London'—and not in the other, it's deleted from that
operand. The rules for deleting through a restriction then come into play again, and the net
effect is that the specified tuple is deleted from relvar S and thus from V2 as well.
So the claims I made earlier do seem to hold up, at least with respect to this first example.
And it's tempting to conclude that, more generally, if views V1 and V2 are equivalent in the
sense illustrated by that example—i.e., if their defining expressions are such that at any given
time they both denote the same relation—then if U is an update on either V1 or V2 , it must be the
 
Search WWH ::




Custom Search