OSQL Reference
This is a reference manual for OSQL. For an easy introduction to OSQL you are recommended to run the SA Engine basics tutorial first.
The type hierarchy
Everything in OSQL is represented as objects managed by the system, both system and user-defined objects. Objects are classified into types making each object an instance of one or several types.
The types are organized in a supertype/subtype hierarchy. The following picture shows the type hierarchy for built-in system types:

The most general type in named Object. All other types are below
Object in the hierarchy. The arrows connecting two types in the
diagram should be read is a.
Visit Basic concepts for a description of the basic built-in types.
The local database
The local database is a built-in main-memory database residing inside each SA Engine peer. It is used for storing models and local meta-data models managed by the peer. It can be populated, queried and updated using the standard database query language SQL. Not only relational database tables but many different kinds of collections can be stored in the local database and queried with SQL extended with computational functions, tensors, streams, and objects in general (i.e. OSQL).
Functions
Functions define the semantics (meaning) of
objects. They represent properties of objects, computations over
objects and relationships between objects. They are basic primitives
in queries and computational models. Functions are objects too and are
instances of the system type Function. Each function has an
associated human readable name called function signature, such as
sin(Real x)->Real, sign(Number x)->Integer and simstream(Real
pace)->Stream of Real.
Properties of artifacts, i.e. their meta-data model, are defined by creating functions, tables, types, and objects describing the artifacts known by an SA Engine peer. Artifacts can be, e.g., machine parts, its manufacturer, mounted sensors, what they are measuring, etc.
Section Functions describes the how to use functions in queries and computations.
The Read-Eval-Print-Loop
The user may enter OSQL statements to an interactive interface such as SA Studio or a Unix/Windows shell in order to instruct the system to do operations such as evaluating expressions, making queries, accessing server, giving instructions to SA Engine, or managing the local database.
The statements are evaluated immediately by SA Engine through its Read-Eval-Print-Loop, REPL. It reads OSQL statements from standard input. The value from the evaluation of each statement is then immediately printed on standard output.
Examples:
1+sin(3)
range(3)
You can enter more than one statement to the REPL by separating them
with a ;.
Examples:
"Hello" + " world";
sin(4) + sqrt(9) * 2;
rand(100)+1
When using the SA Engine Console
REPL in Unix/Windows shells, OSQL
statements must be terminated by a semicolon (;). As shown above,
the ; is not needed when evaluating a single statement to the REPL
in your browser or in SA Studio.
Organization
This reference manual is organized as follows:
The system types of OSQL are described in Basic concepts.
The use of standard SQL SQL syntax for managing tables in the local databaese is described in SQL Tables and Queries.
General extended SQL queries and computations over the local database are presented in Queries.
A central concept in SA Engine is the extensive use of functions in computational models and queries as described in Functions.
Queries and computations can produce ordered sequences of objects called Vectors.
Models analyzing numerical data such as sensor readings are often defined in terms of multi-dimensional arrays or tensors. The definition and querying of multi-dimensional arrays is described in Arrays and tensors.
The use of temporal data is important for many applications and documented in Time.
The reduce function provides a powerful mechanism to analyze data and collect statistics with small memory footprint.
How to define queries and computational models over data continuously streaming through SA Engine is described in Streams.
Visit Stateful and procedural functions for explaining the definition and processing of functions that have side effects or change their internal state each time they are called.
Graphs and trees can be explored using graph traversal functions.
Binary data can be created and accessed in queries, which is important for efficient data representation and when interfacing external data and systems.
New types can be defined as user-defined types.
