Skip to main content

OSQL Reference

This is a reference manual for OSQL. For an easy introduction to OSQL you are recommended to run the System tutorial.

Objects, types and functions

Everything in OSQL is represented as objects managed by the system, both system and user-defined objects. There are three main kinds of representations of objects: literals, collections, and surrogates.

Examples of literals are numbers and strings. They are self-contained atomic objects which are automatically removed by the system when no longer used.

Examples of collections are bags (sets that may contain duplicates), vectors, arrays, and streams. They contain other objects as elements. Collections are automatically removed by the system when no longer needed.

Surrogates are objects that are explicitly created and deleted by the user and stored in the local main-memory database inside SA Engine. They are identified by explicit object identifiers (OIDs). Examples of surrogates are objects representing real-world entities such as sensors, system objects such as functions, or SA Engine peers.

Objects are classified by a hierachy of types having an associted name called type signature, such as Integer, String, Array, Vector of Integer, and Stream.

Functions define the semantics (meaning) of objects. They represent properties of objects, computations over objects, and relationships between objects. They furthermore are basic primitives in queries and models. Functions are objects too and are instances of the system type Function.

Properties of artifacts, i.e. their meta-data model, are defined by creating functions, 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.

Statements, expressions and queries

The SA Engine REPL (Read-Eval-Print-Loop) reads OSQL statements from standard input in an SA Studio browser tab or a Windows/Unix console. The value from the evaluation of each statement is then immediately printed on standard output.

The simplest form of statements are expressions, which are formulas expressed with the OSQL syntax, e.g. 1+sin(3). Complex expressions can be built up in terms of other expression. Expressions are basic building blocks in all kinds of OSQL statements.

Expressions are the simplest form of OSQL queries. Complex queries can be formed by select expressions.

In addition to expressions there are OSQL statements that instruct SA Engine to perform certain tasks like updating or saving the local database.

The user may enter different kinds of OSQL statements to an interactive OSQL 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 using the built-in database.

Organization

This reference manual is organized as follows:

The local main-memory database inside each SA Engine peer is used for storing models and local meta-data about data and streams managed by the peer. The local database can be defined, populated, queried and updated by OSQL statements.

  • Defining Types describes how to create a simple database schema in the local database by defining types and properties.

  • A central concept in sa.engine is the extensive use of functions in models and queries. There are several kinds of user-defined functions supported by the system as described in Defining Functions.

  • Creating Objects describes how to populate the local database by creating objects.

  • The concepts of queries and computations over the local database are presented in Queries.

  • SA Engine provides the ability to specify vector queries, which return ordered sequences of data, as described in Vector Queries.

  • How to define queries and models over data continuoisly streaming through SA is described in Stream Queries and Functions.

  • 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.

  • Updates describes how to update a populated database.