Language Concepts
The basic entity in OQL is the atom. An atom is the result of the
evaluation of any expression. Atoms are manipulated through expressions.
Although OQL is not fully an expression language as some valid constructs, such
as flow controls, are not expressions, the expression is the basic
concept of OQL.
The non-expression constructs, such as selection and iteration statements,
control the flow (or evaluation) of expressions.
An expression is built from typed operands composed recursively by operators.
OQL is a typed language: each atom has a type. This type
can be an OQL builtin type or can be derived from the schema type
declarations.
OQL binds the EYEDB object model by providing a mapping between OQL builtin
types and the EYEDB object model types. As in the EYEDB object model,
OQL supports both object entities (with a unique object identifier)
and literal entities (with no identifier).
The concept of object/literal is orthogonal to the concept of type, this
means that any type may have object instances and literal instances.
For instance, one can have literal or object integers, literal or
object collections.
For instance, the following constructs produces a literal integer:
1; // OQL interpreter generates a literal integer
first(select x.age from Person x); // database produces a literal integer
// bound to an atom of type integer
while the followings produce respectively a Person object and
a literal collection of Person objects:
first(select x from Person x);
select x from Person x;
An EYEDB object is always bound
in OQL to an atom of type oid or of type object.
A literal is bound to the corresponding direct type in OQL using a trivial
mapping. For instance, a literal entity of the EYEDB type integer
is bound to an OQL atom of the OQL type integer; while an
object entity of the EYEDB type Person is bound to an OQL atom
of type oid or object.
We introduce now the OQL builtin types and the way that they are generated.
OQL includes 15 builtin types as follows:
- integer
- string
- float
- char
- boolean
- identifier
- set
- bag
- array
- list
- struct
- oid
- object
- null
- nil
Some of these atoms can be expressed as terminals of the OQL grammar - for
instance integer, float, string - others are
generated using syntaxic constructions such as function calls or specific
constructions - for instance list, bag, struct.
We will introduced first the syntax of the atoms which can be expressed
as terminals, then the way to produce non terminal atoms.
EyeDB manual