Database Reference
In-Depth Information
time-dependent fields. However, lifted operators must be renamed to differen-
tiate those that operate on space or on time. For example,
sum_s
and
sum_t
correspond to the
sum
operator lifted in space and in time, respectively. Thus,
given a set of time-dependent fields
t
i
representing the number of cars of type
i
that are present at a location in space at a particular instant,
sum s
(
{
t
i
}
) will
result in a time-dependent field
t
obtained by applying the operator
sum_t
to each point in space, because each point in space defines a time-dependent
real. Similarly,
sum t
(
{
t
i
}
) will result in a time-dependent field
t
obtained by
applying the operator
sum_s
to each instant, since each instant defines a field
of reals.
In addition, new spatio-temporal operators have to be defined. For example,
operators
atMPoint
,
atMLine
,and
atMRegion
restrict the field to a given
subset of the spatio-temporal cube defined by a time-dependent spatial value.
In particular, projecting a time-dependent field to a time-dependent point with
function
atMPoint
will keep only the points in the field that belong to the
moving track of the point (i.e., a 3D line in the cube).
Consider the following query, which involves the field
LandUse
.
Query 4.6. “Give the average duration of the trajectories that started in a
residential area and that ended in an industrial area on February 1, 2012.”
AVG(SELECT j.duration
FROM Trajectory j, LandUse l
WHERE date(j.startTime)=1/2/2012 AND date(j.endTime)=1/2/2012
AND intersects(j.startLocation,defspace(at(l,'Residential'))),
AND intersects(j.endLocation,defspace(at(l,'Industrial'))))
Here, function
at
projects the land use field to the values of type residential
or industrial, function
defspace
obtains the geometry of the restricted field,
and function
intersects
ensures that the start or end location is included in
the obtained geometry. Because it is supposed that the attribute
startTime
is of type timestamp, function
date
is used for obtaining the corresponding
date.
The next query involves the time-dependent field
Temperature
.
Query 4.7. “For episodes that occurred on February 1, 2010, give the average
speed and the maximum temperature during the episode.”
SELECT e.number, e.avgSpeed, mmax(atMLine(l,e.route))
FROM Episode e, Time t, Temperature l
WHERE e.time=t.id AND t.date=1/2/2010