Databases Reference
In-Depth Information
f or some d1 d2 and/or some i1 i2 , where in accordance with the conditions spelled out above
d1 - r = d2 - r = r
i1 = r
i2 = d1
i1 = d2
i2 = Ø. Then:
Let t d1 - d2 . Since d1 - r = Ø, t r - d2 and t r - d1 . Hence t r - d2
i2 ;
therefore t r - d1
i1 . Since t r - d1, t i1 . But then d1
i1 ≠ Ø, which is a
contradiction; hence no such t exists and d1 - d2 = Ø (i.e., d1
d2 ). A similar argument
⊆ᅠ
shows d2
d1 . Hence d1 = d2 .
⊆ᅠ
We thus have r - d1 = r - d2 = z, say. Then z
i1 = z
∪ᅠ
i2 . But r
i1 = Ø, so
( r - d1 )
i1 = Ø, so z
i1 = Ø. A similar argument shows z
i2 = Ø. Hence, since
z
i1 = z
i2, i1 = i2 .
It follows from the foregoing that if x is the relation to be assigned to R, then x can be
expressed as either r - d
i - d (i.e., it makes no difference whether we “do the delete
first” or “do the insert first”). It further follows that, given r and x , we have:
i or r
d = r - x
i = x - r
Now, to repeat a point I made earlier, an INSERT is basically an assignment for which d is
empty, and a DELETE is basically an assignment for which i is empty. But now I'd like to say
something about UPDATE specifically (by which I mean, of course, explicit UPDATE
operations). Clearly, d and i must both be nonempty (in general) for such an operation. In fact,
let's consider the generic form of such an operation:
UPDATE R WHERE bx : { A := ax }
Here R is a relvar reference; bx is a boolean expression (default simply TRUE); A is some
attribute of relvar R ; and ax is an expression denoting a value a of the same type as A . (For
simplicity I limit my attention to the case of an UPDATE involving just the single “attribute
assignment” A := ax . The discussion that follows can obviously be generalized to the case of an
UPDATE involving two or more such assignments.)
Given this UPDATE, then it should be clear that the delete set d is defined as follows (I
remind you that the symbol “
” means “is defined as”):
d
{ t : t R AND bx ( t ) AND t . A ax }
Explanation: What this definition means is that d consists of just those tuples t such that, first, t
appears in R ; second, bx evaluates to TRUE for t ; and third, the A value within t isn't equal to a
already.
The insert set i is then defined in terms of d , thus:
 
Search WWH ::




Custom Search