Databases Reference
In-Depth Information
This expression yields the relation we earlier called RESULT. In other words,
now showing all the steps together (and simplifying slightly), RESULT is the
result of evaluating the following overall expression:
WITH SP_DURING {S#, DURING} AS T1,
(T1 GROUP (DURING) AS X) AS T2,
(EXTEND T2 ADD COALESCE (X) AS Y) {ALL BUT
X} AS T3 :
T3 UNGROUP Y
Obviously it would be desirable to be able to get from T1 to RESULT in a
single operation. To that end, we invent a new relation coalesce operator,
with syntax as follows:
R COALESCE A
(where R is a relational expression and A is an attribute—of some interval
type—of the relation denoted by that expression).
11
The semantics of this
operator are defined by obvious generalization of the grouping, extension,
projection, and ungrouping operations by which we obtained RESULT from
T1. Note: It might help to observe that coalescing R on A involves grouping
R by all of the attributes of R other than A (similarly, the expression T1
GROUP (DURING)
, for example, can be read as group T1 by S#, S#
being the sole attribute of T1 not mentioned in the GROUP clause).
Putting all of the foregoing together, we can now offer the following as
a reasonably straightforward formulation of Query 4.1:
¼
SP_DURING { S#, DURING } COALESCE DURING
Note: The overall operation denoted by this expression is an example of what
some writers call temporal projection. To be more specific, it is a temporal
projection of SP_DURING over S# and DURING. (Recall that the origi-
nal version of this query, Query 1.1, involved the ordinary projection of SP
over S#.) Observe that temporal projection is not exactly a projection as such
but is, rather, a temporal analog of an ordinary projection.
We now move on to Query 3.2. Query 4.2 is a restatement of that query
in terms of the database of Table 5.4:
11. The A operand could be extended to permit a comma list of attribute names, if desired.
Analogous remarks apply to the relation unfold and temporal difference operators
also.
 
Search WWH ::




Custom Search