by Fabio [Allanon] Falcucci

SDB Engine Alpha1 is out! Check it out in the download section!

INTRODUCTION

This guide will try to explain how SDB Engine works and how it can be used; the objective is to make a database engine easy to handle and efficient.

First of all some credits...
The project is developed with the LUA porting for AROS and it is tested/developed under i386 AROS native and Windows hosted with QEmu, the code is edited with JanoEditor (AROS), Kate (Linux) and PSPad while the documentation is written using OpenOffice (Linux); The tools involved in the web publishing are PSPad and Nvu; the os platforms involved in this project are AROS, Mandriva (Linux), Knoppix (Linux) and Windows.


This is my project for AROS since, at the moment, seems to have few original software and no database programs to run; the SDB Project is part of a bigger one started in the 2000, it is very huge and maybe I will born again two or three times to complete it ^_^' of course I love programming and I want to improve my skills!

I've chosen the LUA programming language for two reasons:

Since I've no time to learn another complex language like C, I've found LUA very simple to understand and use, I was able to start to code very soon after reading few pages of the guide.

Concluding this brief introduction SDB means Simple Data Base.

PROJECT OVERVIEW

The "database" concept has been simplified on the SDB Engine respect to other well known databases; here a database is composed by a single table: this is not a limit since we can create relations between databases, but with this design the engine will be more efficient and fast ( At least I hope so ^_^ ).

The engine can open at the same time many databases, and for each one, we can have many record subset called Selections; selections are filtered applying some filter criteria to the database or to an existing selection.

Selections can be exported in various formats.

Selections can be merged using boolean operators like "And", "Or", "Not" and "Xor".

Relations between databases are called Links but at the moment I'm still studying a way to implement this important feature without slowing-down the entire engine.

All warning/error messages returned by functions/commands are very detailed and they can be localized simply editing a Lua script. As standard language I've planned english but at any moment the user can change it with a simple command ( if the language is supported ), or setting it in the preferences.

At this coding stage the SDB Engine can be used with the Lua console or using Lua scripts, for some time I've tested the Zune binding available for the AROS port of LUA (thanks Mazze!) with good results, but now my first goal is to publish a first alpha release just to get some feedback and find out nasty bugs.

THE DATABASE: A TABLE

As I've said the databases data source is only a table, this one can be composed by a number of records and a record can be composed by a fixed number of fields, supported fields are only three ( at the moment ), they can be of numeric, alphanumeric or boolean type.

Generally the timeline of a database will be:

At the opening time we have to assign a name to the database we want to open called Alias, subsequently we can refer to the database with this simpler name instead of the file name.

There is a blog which I frequently keep updated with the overall project status, you can read detailed information at the SDB Project Blog.

Below there is a script sample that creates a database, adds a record and then close the database. For simplicity will not be handled function's errors; this code sample is just to know how an SDB script looks like.

-- make a lua table an load it with the data that define the record structure
structure[1] = { name = "Name", type = 2 }
structure[2] = { name = "Surname", type = 2 }
structure[3] = { name = "Age", type = 1 }

-- create the new database
sdb.db.NewDB( "ram:testDB", structure, 1 )

-- now open the just created database
sdb.db.OpenDB( "ram:test.sdb", "MyDB" )

-- add a record
myRecord [1] = { name = "Name", data = "Fabio" }
myRecord [2] = { name = "Surname", data = "Falcucci" }
myRecord [3] = { name = "Age", data = 34 }
sdb.record.Append( "MyDB", myRecord )

-- finally close the database
sdb.db.CloseDB( "MyDB" )

SDB MAIN FEATURES

Below there are some SDB features and limitations: