Step 1: Database Definition

Before you begin using eXtremeDB, it is important to understand some basic concepts. For database applications using the C API, development consists of three stages on the host environment:

These basic steps in building an eXtremeDB C application are illustrated in the following diagram; the host components are in blue, while the target components are in red:

Schema definition

The database schema is defined in a high-level C-like Data Definition Language (DDL). The essential DDL statements are a declare database <db_name> to assign the database name, and a class <class_name> to define a database class (corresponds to a table in SQL jargon). For example, the following defines a simple database with name mydb and a single class (table) MyClass with two fields id (an unsigned 4-byte integer) and name (a variable length character string):

 
    declare database mydb;
     
    class MyClass {
        unsigned<4> id;
        string name;
    };
     

Compiling the schema

Typically the schema file will be named with extension .mco; like schema.mco or mydb.mco. Then this file is compiled by the DDL compiler mcocomp to produce the schema-specific database dictionary and data access APIs in the form of a <db_name>.h header file and a <db_name>.c implementation file. For example the following command will produce files mydb.h and mydb.c in the current working directory:

 
    ../../host/bin/mcocomp mydb.mco
     

A more interesting example of DDL usage can be seen in the SDK sample samples/native/core/00_ddl/schema.mco.

Implementing eXtremeDB APIs in the application source code

A number of "helper" functions are provided in directory samples/native/common that can facilitate initial development. The simplest of eXtremeDB applications can merely include the common.h header file, then call helper functions sample_os_initialize(), print out a "Hello world" type message, call sample_pause_end() to pause execution, then sample_os_shutdown() to terminate. Please see the SDK sample samples/native/core/00_ddl/main.c for an example.

Compiling and linking the application

At a minimum, a simple application that creates an eXtremeDB database in conventional memory will require the following libraries (by convention we use abbreviated naming, for example, mcolib which will exist as mcolib.lib on Windows platforms and libmcolib.a on Unix-Linux platforms):

mcolib The “core” runtime library
mcovtmem The “virtual tables” library for all-in-memory databases
mcomconv The “memory devices” library for conventional memory
mcosw32, mcosw32n, or mcoslnx The “synchronization” library
mcouwrt The “utilities” library

Please refer to the SDK sample samples/native/core/00_ddl for a very simple example, and building and running SDK samples for instructions.

In the next steps we will add some database functionality to applications. The best way to learn these details is to build and run the sample applications and examine the source code described in these steps.