Databases Reference
In-Depth Information
coalesced form are not standard terms; in fact, there do not appear to be any
standard terms for these concepts, even though the concepts as such are cer-
tainly discussed in the literature.
These two canonical forms both have an important part to play in
the solutions we are at last beginning to approach to the problems discussed
in Section 5.3. However, the UNFOLD and COALESCE operators are still
not quite what we need (they are still just a step on the way); rather, what we
need is certain relational counterparts of these operators, and we will define
such counterparts in the section immediately following.
5.8
Relational Operators Involving Intervals
The scalar operators on intervals described in Section 5.6 are of course avail-
able for use in scalar expressions in the usual places within relational expres-
sions. In Tutorial D, for example, those places are basically WHERE clauses
on restrictions and ADD clauses on EXTEND and SUMMARIZE. Using the
database of Table 5.4, therefore, the query Get supplier numbers for suppliers
who were able to supply part P2 on day 8 might be expressed as follows:
(SP_DURING WHERE P# = P# (P2) AND d08 IN DURING) {S#}
Explanation: We take the restriction of SP_DURING consisting of tuples
whose P# values are the part number P2 and whose DURING values contain
the point d08; then we project that result over just the supplier number
attribute, S#. Note: In practice, the expression d08 here would have to be
replaced by an appropriate literal of type DAY.
As another example, the following expression yields a relation showing
which pairs of suppliers were located in the same city at the same time,
together with the cities and times in question:
EXTEND
((((S_DURING RENAME S# AS XS#, DURING AS XD)
{XS#, CITY, XD}
JOIN
(S_DURING RENAME S# AS YS#, DURING AS YD)
{YS#, CITY, YD})
WHERE XD OVERLAPS YD)
ADD (XD INTERSECT YD) AS DURING) {XS#, YS#,
CITY,DURING}
Search WWH ::




Custom Search