Databases Reference
In-Depth Information
Aside: By the way, note that there's a logical difference between multivariable constraints
and what SQL and Relational Theory calls multirelvar constraints. A multivariable
constraint is one that involves involves two or more range variables; a multirelvar
constraint is one that involves two or more relvars. Now, it's certainly true that every
multirelvar constraint is also a multivariable constraint, but the converse is false—the range
variables in a multivariable constraint might all range over the same relvar (e.g., see the
next example but one). End of aside .
Here are some more examples of multivariable constraints (all of them based on relvars S
and/or LS and/or NLS):
No supplier number appears in both LS and NLS:
FORALL x LS ( FORALL y NLS ( x .SNO y .SNO ) )
{SNO} is a key for each of S, LS, and NLS (for simplicity, I show the constraint for relvar
S only):
FORALL x S ( UNIQUE y S ( x .SNO = y .SNO ) )
Note: In case you're unfamiliar with the UNIQUE quantifier, it can be read as “there exists
exactly one … such that.”
{SNO} in LS is a foreign key, referencing the key {SNO} in S:
FORALL x LS ( UNIQUE y S ( x .SNO = y .SNO ) )
S is equal to the (disjoint) union of LS and NLS:
FORALL x S ( UNIQUE y LS ( x = y ) OR UNIQUE y NLS ( x = y ) ) AND
FORALL y LS ( UNIQUE x S ( x = y ) AND
FORALL y NLS ( UNIQUE x S ( x = y )
At any given time, LS is equal to that restriction of S where the CITY value is London:
FORALL x LS ( UNIQUE y S ( x = y ) AND
FORALL y S ( IF y.CITY = 'London' THEN UNIQUE x LS ( x = y ) )
Now (at last) we come to the point of this perhaps rather lengthy digression. In Chapter 1,
I introduced the idea of compensatory actions, which are additional updates that are performed
 
Search WWH ::




Custom Search