VIEWS AND SNAPSHOTS
Throughout this chapter, I’ve been using the term view in its original sense—the sense, that is, in which (in the relational context, at least) it was originally defined. Unfortunately, however, some terminological confusion has arisen in recent years: certainly in the academic world, and to some extent in the commercial world also. Recall that a view can be thought of as a derived relvar. Well, there’s another kind of derived relvar too, called a snapshot. As the name might tend to suggest, a snapshot, although it’s derived, is real, not virtual—meaning it’s represented not just by its definition in terms of other relvars, but also (at least conceptually) by its own separate copy of the data. For example (to invent some syntax on the fly):
VAR LSS SNAPSHOT ( S WHERE CITY = 'London' ) KEY { SNO } REFRESH EVERY DAY ;
Defining a snapshot is just like executing a query, except that:
The result of the query is saved in the database under the specified name (LSS in the example) as a “read-only relvar” (read-only, that is, apart from the periodic refresh—see the bullet item immediately following).
Periodically (EVERY DAY in the example) the snapshot is refreshed, meaning its current value is discarded, the query is executed again, and the result of that new execution becomes the new snapshot value. (Of course, other REFRESH options are possible: for example, EVERY MONDAY, EVERY 5 MINUTES, EVERY MONTH, and so on.)
In the example, therefore, snapshot LSS represents the data ...
Get SQL and Relational Theory, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.