Databases Reference
In-Depth Information
This view is a “restriction view”—its defining expression calls for invocation of a certain
restriction operation on relvar S—and its type is therefore the same as that of relvar S, viz.,
RELATION {SNO CHAR, SNAME CHAR, STATUS INTEGER, CITY CHAR}.
More generally, however, a view is a relvar and is thus subject to what in Chapter 2 I called
a total relvar constraint (for the relvar in question). But the total relvar constraint that applies to
a view V is, at least in part, a derived constraint: It's derived—again, at least in part—from the
constraints for the relvars in terms of which V is defined, in accordance with the semantics of the
relational operations involved in the view defining expression. In the case of view LS, for
example, the total relvar constraint is the logical AND of:
a. The total relvar constraint for relvar S, and
b. The restriction condition (CITY = 'London') specified in the view defining expression. 10
In other words, view LS is subject to all constraints that apply to relvar S—e.g., the constraint
that {SNO} is a key— and the constraint that the city is London. Note, therefore, that The
Golden Rule applies to views just as much as it does to base relvars.
Let's agree to use the term view constraint to refer to any constraint that applies to some
view. Now, even if view constraints can be derived as in the foregoing example, it doesn't
follow that there's no need to declare them explicitly (for one thing, the system might not be
“intelligent” enough to determine those constraints for itself, automatically). Thus, it should
certainly be possible to declare explicit constraints for views. In particular, it should be possible
(a) to include explicit KEY and FOREIGN KEY specifications in view definitions and (b) to
allow the target relvar in a FOREIGN KEY specification to be a view. The following example
illustrates both of the possibilities mentioned under (a) here:
VAR LS VIRTUAL ( S WHERE CITY = 'London' )
KEY { SNO }
FOREIGN KEY { SNO } REFERENCES S ;
Next , a view is a relvar and therefore has a relvar predicate, in which the parameters
correspond one to one to the attributes of the relvar—i.e., the view—in question. But the
predicate that applies to a view V is a derived predicate: It's derived from the predicates for the
relvars in terms of which V is defined, in accordance with the semantics of the relational
10 In general, it should be clear that the relation denoted at any given time by the restriction expression rx WHERE bx must
satisfy all constraints that apply to the relation denoted by the relational expression rx and the constraint denoted by the boolean
expression bx (in other words, WHERE is AND, loosely speaking). Note: The constraint represented by bx here is a restriction
condition . See Appendix B for a precise definition of this concept.
Search WWH ::




Custom Search