Databases Reference
In-Depth Information
ON DELETE d FROM S , INSERT i INTO S :
DELETE d { SNO , STATUS } FROM ST , DELETE d { SNO , CITY } FROM SC ,
INSERT i { SNO , STATUS } INTO ST , INSERT i { SNO , CITY } INTO SC ;
Aside: Again we have a situation—actually it arises in connection with both of the
foregoing combined rules—in which two or more of the individual assignments within
some multiple assignment specify the same target variable. But it's easy to see that the
sequence in which those individual assignments are executed makes no difference to the
overall outcome anyway, in these particular cases. Again, see Appendix A for further
explanation. End of aside .
Now let's think about explicit UPDATE operations. First, I'll leave it as an exercise to
show that explicit UPDATEs on relvar S all work as you would intuitively expect. (To convince
yourself of this fact, you might like to consider the following examples:
UPDATE S WHERE SNO = 'S1' : { CITY := 'Paris' } ;
UPDATE S WHERE SNO = 'S1' : { SNO := 'S9' } ;
Note in particular that the second of these examples is a “key UPDATE.”)
But what about UPDATEs on ST and SC? By way of example, consider the following
UPDATE request on ST:
UPDATE ST WHERE SNO = 'S1' : { STATUS := 10 } ;
Given our usual sample values, what happens here is as follows:
1. First, the requested update is done—i.e., the tuple (S1,20) is deleted from relvar ST and the
tuple (S1,10) is inserted into relvar ST.
2. Second, the compensatory actions are performed—i.e., the tuple (S1,20,London) is deleted
from relvar S, thanks to the cascade delete rule from ST to S, and the tuple (S1,10,London)
is inserted into relvar S, thanks to the cascade insert rule from ST to S. Note: Observe that
dc and ic are both empty in this example. As a consequence, the symbol “SC” in the
expression it JOIN SC, in the rule for INSERTs on ST and SC, effectively denotes the
value of relvar SC as it was before any updating is done, and that expression therefore
yields the desired S tuple (S1,10,London).
So this UPDATE works just fine. But what about the following “key UPDATE”?—
 
Search WWH ::




Custom Search