Now we come to what in many ways is the most important part of this chapter. The essence of it is this: there's another way to think about relvars. I mean, most people think of relvars as if they were just files in the traditional computing sense rather abstract files, perhaps (maybe disciplined would be a better word than abstract), but files nonetheless. But there's a different way to look at them, a way that I believe can lead to a much deeper understanding of what's really going on. It goes like this. Consider the suppliers relvar S. Like all relvars, that relvar is supposed to represent some portion of the real world. In fact, I can be more precise: the heading of that relvar represents a certain predicate, meaning it's a kind of generic statement about some portion of the real world (it's generic because it's parameterized, as I'll explain in a moment). The predicate in question looks like this:
This predicate is the intended interpretation in other words, the meaning, also called the intension (note the spelling) for relvar S. You can think of a predicate as a truth-valued function. Like all functions, it has a set of parameters, it returns a result when it's invoked, and (because it's truth-valued) that result is either TRUE or FALSE. In the case of the predicate just shown, for example, the parameters are SNO, SNAME, STATUS, and CITY (corresponding to the attributes of the relvar, of course), and they stand for values of the applicable types (SNO, NAME, INTEGER, and CHAR, respectively). When we invoke the function when we instantiate the predicate, as the logicians say we substitute arguments for the parameters. Suppose we substitute the arguments S1, Smith, 20, and London, respectively. Then we obtain the following proposition:
In general, a proposition in logic is a statement that's unconditionally either true or false. Here are a couple of examples:
The first of these is true and the second false. Don't fall into the common trap of thinking propositions must always be true ones! However, the ones I'm talking about in connection with relvars are supposed to be true ones specifically, as I now explain:
Hence, given our usual sample value for relvar S, we assume the following propositions all evaluate to TRUE:
And so on. What's more, we go further: if a certain tuple plausibly could appear in some relvar at some time but in fact doesn't, then we assume the corresponding proposition is false at that time (in other words, we adopt what's called the Closed World Assumption). For example, the tuple: TUPLE { SNO SNO('S6'), SNAME NAME('Lopez'), STATUS 30, CITY 'Madrid' } is let's agree a plausible supplier tuple but doesn't appear in relvar S at this time, and so we assume it's not the case that the following proposition is true at this time:
In other words, a given relvar contains, at any given time, all and only the tuples that represent true propositions (true instantiations of the predicate) at that time.
Relational ExpressionsThe ideas I've been discussing in this section all extend in a natural way to apply to arbitrary relational expressions. For example, consider this expression, which represents the projection of suppliers on all attributes but CITY: S { SNO, SNAME, STATUS } The result contains all tuples of the form: TUPLE { SNO s, SNAME n, STATUS t } such that a tuple of the form: TUPLE { SNO s, SNAME n, STATUS t, CITY c } currently appears in S for some CITY value c. In other words, the result represents the current extension of a predicate that looks like this:
Observe that this predicate has just three parameters and the corresponding relation (the projection of suppliers on all but CITY) has just three attributes CITY is not a parameter but what the logicians instead call a bound variable, owing to the fact that it's "quantified" by the phrase there exists some city. (See Appendix A for further explanation of bound variables and quantifiers.) A possibly clearer way of making the same point that the predicate has just three parameters, not four is to observe that the predicate in question is logically equivalent to this one:
It follows from all of the above that views in particular represent certain predicates. For example, if view SST is defined as follows: VAR SST VIRTUAL ( S { SNO, SNAME, STATUS } ) ; then the relvar predicate for SST is precisely:
There's one last point I want to make here about predicates and propositions. I've said a predicate has a set of parameters. As usual, however, that set might be empty and if it is, the predicate becomes a proposition! (Certainly it's a statement that's unconditionally either true or false.) In other words, a proposition is a degenerate predicate; all propositions are predicates, but most predicates aren't propositions. |