Developed at the

Polish-Japanese Institute of Information Technology

Chair of Software Engineering

SBA and SBQL home pages

© Copyright by ODRA team, © Copyright by PJIIT





ODRA – Object Database for Rapid Application development

Description and Programmer Manual




by Kazimierz Subieta and the ODRA team


3. Getting Started

3.1 ODRA Operational Environment

The ODRA database system architecture uses the client/server model to communicate with clients creating distributed database environment. It is also possible that the ODRA server can behave as a client for another server. As typical for client/server applications, the client and the server can be on different hosts. In such a case they communicate over the TCP/IP network.

3.1.1 ODRA server

An ODRA database is a static collection of structures called a “data store”. Data stores can be persistent or transient. In the first case the data are stored in the operating system file (stored in RAM with the use of a facility called memory mapped files that is similar to the swap file mechanism). The transient data store is stored directly in the main memory.

A collection of processes operating on a database is called a database instance. Currently a database instance consists of two main processes:

·         Communication process – responsible for asynchronous client connections acceptance and service.

·         Server process – representing client at the server side.

3.1.2 ODRA client

An ODRA client is an application that is able to communicate with an ODRA server with the use of ODRA client/server protocol or API (e.g. Web Services interface). By default, the ODRA system is equipped with command line interface client (CLI). To create a complex application the IDE (Integrated Development Environment tool) client can be used.

3.2 ODRA Installation Guide

ODRA is a Java-based application and requires Sun™ JRE (Java Runtime Environment) to run. The current version uses the 1.6+ version of the JRE.

Because ODRA is assumed to be a full development environment the main usage pattern is based on the Integrated Development (IDE) application. IDE contains a graphical editor (which plays the role of rich ODRA client) and the ODRA server itself (for storing programs, compiling and execution). Apart from IDE, ODRA is also equipped with a client that can be used instead of the full IDE tool.

3.3 Your First Tiny Object Base

After completing previous steps you are ready to create your own data structures and classes. The following sample code creates PersonClass , extends it by EmpClass and creates DeptClass:


class PersonClass {

   instance Person : {






   getLastName():string {return lName;}

   getFullName():string {return lName + " " + fName;}



class EmpClass extends PersonClass {

   instance Emp : {


   worksIn: ref Dept;


   getFullName():string {

      return "Employee " + lName + " " + fName;}

   getSal():integer {return salary;}

   giveRise(amount:integer) { sal := sal + amount; }



class DeptClass {

   instance Dept : {

   dNbr: integer;

   dName: string;

   loc: string [1..*];

   employs: ref Emp [0..*];




Having classes defined it is possible to fill the database by sample data and to query database using sample queries:


module PersonEmpMod {

   class PersonClass {…} // as before

   class EmpClass extends PersonClass {…} // as before

   class DeptClass {…} // as before


   Emp: EmpClass [0..*];

   Dept: DeptClass [0..*];



      e1: ref EmpClass;

      e2: ref EmpClass;

      e3: ref EmpClass;

      d1: ref DeptClass;

      d2: ref DeptClass;


      d1 := create permanent Dept(

         445566 as dNbr,

         "Ads" as dName,

         bag("Rome", "Paris") groupas loc);


      d2 := create permanent Dept(

         778899 as dNbr,

         "Toys" as dName,

         "London" as loc);


      e1 := create permanent Emp(

         "Tom" as fName,

         "Jones" as lName,

         "M" as sex,

         34 as age,

         3000 as sal,

         d1 as worksIn );


      e2 := create permanent Emp(

         "John" as fName,

         "Doe" as lName,

         "M" as sex,

         40 as age,

         4000 as sal,

         d1 as worksIn );


      e3 := create permanent Emp(

         "Jane" as fName,

         "Poe" as lName,

         "F" as sex,

         29 as age,

         2000 as sal,

         d2 as worksIn );


      d1.Dept :<< employs( bag(e1,e2));

      d2.Dept :<< employs (e3);




3.4 Your First SBQL Queries and Programs


Queries (in the context of PersonEmpMod):

Return all employees with last name Doe.

Emp where lName = “Doe”

Return all employees with salary greater than 2000.

Emp where sal > 2000


Simple application could be implemented like this:

module test {

   import admin.PersonEmpMod;


   say_hello():string [0..*] {


   return Emp.(“Hello ” + fName + “ ” + lName + “!”);



We can invoke Hello World application invoking say_hello() procedure (in the context of module test):

> say_hello();

The procedure will return the following output:

Hello Tom Jones! Hello John Doe! Hello Jane Poe!


3.5 Using Integrated Development Environment

The comprehensive description of using IDE is the subject of a next chapter of this document. This section contains only quick start guide with the IDE. Notice also that the description of ODRA IDE from the programmer point of view is the subject of another document, ODRA-IDE API Specification (070621 ODRA-IDE API Specification.doc).

The following steps describe activites needed by the quick start example:

·        Working with the IDE should be started with creating a new project. This functionality is available using context menu – see Fig. 31. A project’s name should be entered (i.e. Tiny Example) and project’s directory has to be selected. Notice that a new project’s directory (with a project’s name) will be created.

3‑1. Creating a new project in the ODRA-IDE

·         Create an empty file (using project’s context menu) named: “PersonEmpMod.sbql” and fill it with the code shown on  Fig. 32 and Fig. 33.



3‑2. SBQL code for PersonEmpMod.sbql – part (a)

3‑3. SBQL code for PersonEmpMod.sbql – part (b)

·        Create an empty file (using project’s context menu) named: “main.sbql” and fill it with the code presented on the  Fig. 3-4.

3‑4. SBQL code for main.sbql

·        Start a default server (using server’s context menu) or connect to the existing one – see  Fig. 35.

3‑5. Connecting to existing ODRA server

·         After sucessfuly connection, build the project (using project’s context menu) –  Fig. 36. Notice that server’s node contains modules node which presents the server’s content. A few new items has been created, i.e. classes (PersonClass, EmpClass), procedure (create_database).

·         Activate “Odra Query” tab (default location is at the bottom of the screen) and run create_database procedure ( Fig. 37). Notice that appropriate context module has been selected.

3‑6. ODRA-IDE after successful build of the sample project

3‑7. Running sample procedure in the ODRA-IDE

·        Run other queries or methods, i. e. say_hello and see the results ( Fig. 38).

3‑8 Running sample query in the ODRA-IDE




Last modified: June 17, 2008