Getting your feet wet using the Raijin Database

The Raijin Database engine was designed and built to fill the gap between SQL and Document databases. In this short introductory article we will try to quickly show how the Raijin Database can be used to solve a major headache application developers and product owners face: schema rigidity.

We assume you are already familiar with SQL in general and have used at least one RDBMS product in the past, though this is not a requirement.

First you will need to grab either the rpm or the deb package from the downloads page that you can install on Linux.

To install the Raijin Database engine on Ubuntu, Debian or derivatives you would run the following as root:

dpkg -i raijin-server_0.9.2_amd64.deb

On RedHat, CentOS or other rpm based GNU/Linux distributions you would issue the following command:

rpm -ivh raijin-server-0.9.2-1.x86_64.rpm

There are no additional packages to install and configure. Once the raijin-server package is installed the service can be started as usual:

service raijin-server start

To verify that it is running you should connect to it from a web browser at http://localhost:2500 that should load a basic form you can use to issue commands.

Let us create our first database as usual by entering the following into the form:

create database testdb;

Clicking the Execute button should give an OK as shown below.

Now we proceed to create a table and insert some data:

use testdb;
create table products(name varchar, price int);
insert into products(name, price) VALUES ('pen', 23);

Again this is pretty much the same to what you should be used to.

You can also use another form of the INSERT statement with the SET syntax that MySQL supports:

insert into products set name='shirt', price=99, size='L';

You will notice that executing this query will return with an OK whereas with normal SQL/RDBMS systems it would fail with a schema violation error because the size attribute was not defined in the products table. While it is possible to configure raijin to enforce a schema, normally it will accept attributes (columns) that were not specified when the table was created:

create table products(name varchar, price int);

Providing a schema is actually optional and you can create a table without specifying your attributes (columns) upfront:

create table products();

It will still work and you can even insert data using a JSON syntax:

insert into testdb.products {"name":"mug", "color":"white", "price":42};

To retrieve the data you would use the SELECT statement as usual:

select name, price from testdb.products order by price desc;

The result is returned as a JSON formatted output:


Recently many RDBMS products have added features to support handling semi-structured data such as JSON and XML. For example PostgreSQL has hstore and JSONB support. MariaDB has dynamic columns which add similar capabilities to help with schema rigidity. Unfortunately these solutions feel like a hack and you can't easily switch between your real columns and dynamic columns. With raijin you can use any attribute in the query without any additional weird syntax. All attributes can be referenced normally like a regular column. Note that we use the term attribute instead of column and record instead of row since raijin was designed for storing sparse data also that this terminology is better suited for.

For example you can use the size attribute in the where clause naturally:

select name, price from testdb.products where size='L';

The above should produce the following record as expected:


To select all attributes you would need to use the star '*' as usual:

select * from testdb.products where color='white';

This yields the following record:


Note that there is a special attribute _id in the record. It is a serial number that is automatically added to every newly inserted record.

The nice thing about the HTTP interface is that the same URL can be used as a REST endpoint so that you can simply throw your queries at it using curl or from JS and it will give you the resultset in JSON:

$ curl --data "{\"query\":\"select * from testdb.products where color='white';\"}" http://localhost:2500

There are a lot more features in raijin that you may find useful. We are actively working on adding some of the missing pieces.

Hope that this short introduction has served as a teaser and sparked some interest to download and test the product. Feel free to contact us, sharing your feedback would be much appreciated.

Start using the Raijin database for free

The schemaless database engine built for today's data chall‚Äčenges