Database Reference
In-Depth Information
3.3.2 Writing Queries in Executable Language
The SECONDO kernel provides a complete interface for data manipulation and
querying that is data model independent. It provides the following generic com-
mands:
5
create <ident>: <type expression>
update <ident> := <value expression>
let <ident> = <value expression>
delete <ident>
query <value expression>
A database is essentially a collection of named objects. In the basic com-
mands, a
type expression
is any well-formed expression over the type construc-
tors of the active algebras, and a
value expression
is any expression involving
database objects, constants, and operations of the active algebras. With the basic
commands, one can
create
an object of a given type (with undefined value),
one can
update
the value of an object, one can create a new object whose type
and value are given by the value expression (
let
), one can
delete
an object
from the database, and, finally, one can evaluate an expression and show the
result at the user interface.
In Section
3.2
we have already seen example uses of the
query
and
let
commands. The
query
command has been used to evaluate expressions on
atomic data types. In this sectionwe showhow expressions can actually represent
efficient execution plans for a database system.
Roughly speaking, the basic idea is to write a query like an expression in
relational algebra where operations are applied sequentially to obtain a query
result. However, there are two important differences:
Instead of materializing relations, for efficiency reasons individual tuples
need to be passed between operations (called pipelining).
Operations of relational algebra are descriptive in the sense that their mean-
ing is a mathematical function telling which result relation is derived from
argument relations. For example, the join operation has many different imple-
mentations. In the executable language, operations have associated fixed
algorithms such as specific join methods.
Pipelining is implemented in SECONDO by providing a special type constructor
called
stream
. Operations defined in an algebra can have arguments or results of
5
We only show the basic commands for data manipulation; there are further commands for inquiries
about the system or the database, transactions, import and export, etc.