Database Reference
In-Depth Information
3.2.1 Motivating Examples
Examples are based on a database that is delivered with the SECONDO system
presented in Section
3.3
.SECONDO is open source, so the reader can in fact
install SECONDO and run the example queries.
The example database is called
berlintest
. It contains spatial data about
the city of Berlin and some moving object data. Here we will use the following
database objects. Note that in SECONDO a database may hold not only relations
but also “atomic” objects of any available data type.
Relation
Trains
describes underground trains moving according to schedule
on a certain day in the city of Berlin.
Trains(Id: int, Line: int, Up: bool, Trip: mpoint)
Each tuple describes one train trip by its identifier, the number of the train
line to which it belongs, in which direction along the route it was going, and the
complete movement description in attribute
Trip
.
Further objects are:
train7: mpoint, mehringdamm: point, thecenter: region
Here
train7
is a DB object with a value of type
mpoint
.
mehringdamm
is
an underground train station in Berlin. Finally,
thecenter
is a region roughly
describing the city center.
Let us start with some simple expressions on atomic objects. Expressions are
composed of database objects, constants, and operations. SECONDO provides the
query
command to evaluate expressions, so one can write
query3*4
and
get
12
as a result.
query train7
This is already a very simple expression and it returns a value of type
mpoint
.
In SECONDO, this value is displayed at the GUI as a point at the position of the
start time. The movement can then be animated.
The following operations have already been introduced in the introduction:
→
line
trajectory:
mpoint
→
periods
deftime:
mpoint
at:
mpoint
×
region
→
mpoint
The expressions
train7 at thecenter, trajectory(train7 at thecenter),
deftime(train7 at thecenter)
return
train7
reduced to the times when it was in the city center area, the path
taken in the center, and the time when it was at the center.