Databases Reference
In-Depth Information
type of a given relation in Tutorial D by means of the keyword RELATION followed by the
applicable heading. For example, here's the type for the suppliers relation:
RELATION { SNO CHAR , SNAME CHAR , STATUS INTEGER , CITY CHAR }
Next, there's a logical difference between relations as such and relation variables . 3 Take
another look at Fig. 2.1. That figure shows three relations: namely, the relations that happen to
exist in the database at some particular time. But if we were to look at the database at some
different time, we would probably see three different relations appearing in their place. In other
words, S, P, and SP are really variables—relation variables, to be precise—and like all variables
they have different values at different times. And since they're relation variables specifically,
their values at any given time are, of course, relation values. Note, however, that the legal values
for a given relation variable must all be of the same relation type—i.e., they must all have the
same heading—and the type and heading in question are thereby also considered to be the type
and heading of the relation variable as such.
By way of elaboration on the foregoing ideas, suppose the relation variable S currently has
the value shown in Fig. 2.1, and suppose we delete the tuples for suppliers in London:
DELETE ( S WHERE CITY = 'London' ) FROM S ;
Relation variable S now looks like this:
┌─────┬───────┬────────┬────────┐
│ SNO │ SNAME │ STATUS │ CITY │
├═════┼───────┼────────┼────────┤
│ S2 │ Jones │ 10 │ Paris │
│ S3 │ Blake │ 30 │ Paris │
│ S5 │ Adams │ 30 │ Athens │
└─────┴───────┴────────┴────────┘
Conceptually, what's happened here is that the old value of S (a relation value, of course)
has been replaced in its entirety by a new value (another relation value). Now, the old value
(with five tuples) and the new one (with three) are rather similar, in a sense, but they certainly
are different values. In fact, the DELETE just shown is logically equivalent to, and is indeed
defined to be “shorthand” for, 4 the following relational assignment:
S := S WHERE NOT ( CITY = 'London' ) ;
3 The notion of logical difference , much appealed to by Darwen and myself in technical writings (especially ones to do with The
Third Manifesto ) derives from a dictum of Wittgenstein's: All logical differences are big differences.
4 “Shorthand” in quotation marks because in fact it's longer than what it's supposed to be short for. But that's partly due to the
fact that I'm using an unconventional dialect of Tutorial D (the actual Tutorial D syntax for this DELETE would be DELETE S
WHERE CITY = 'London'). The syntax I choose to use for DELETE (and INSERT) in this topic is deliberately a trifle verbose,
in order that the semantics might be absolutely clear.
Search WWH ::




Custom Search