S Q L a n d V i e w s
A view is a derived relvar; in other words, it’s a relvar that’s explicitly derived (and known to be derived, at least by some people) from certain other relvars. Note: If you’re wondering what the difference is between a derived relvar and a virtual one (see the previous bullet item), I should explain that all virtual relvars are derived but some derived ones aren’t virtual. See the section “Views and Snapshots” later in this chapter.
A view is a “window into” the relvars from which it’s derived; thus, operations on the view are to be understood as “really” being operations on those underlying relvars.
VIEWS ARE RELVARS
Of those informal characterizations listed above of what a view is, the following definition might appear to favor one over the rest─but those informal characterizations are all equivalent anyway, loosely speaking:
Note that these are restriction views─their value at any given time is a certain restriction of the value at that time of relvar S. Some syntax issues:
The parentheses in the SQL examples are unnecessary but not wrong; I include them for clarity. The parentheses in the Tutorial D examples are required.
Note in particular that this latter style means we’re telling the system once instead of twice that one of the view columns is called SNAME.
CREATE VIEW in SQL also allows WITH CHECK OPTION to be specified if (but only if!) it regards the view as updatable. Recommendation: Always specify this option if possible. See the section “Update Operations” for further discussion.