Empowering you to understand your world

Chromia Incorporates Relational Databases Into Blockchain

Chromia is a relational blockchain platform designed with performance and scalability in mind. It checks all the boxes required for mass adoption, including letting dApps pay fees so that users don’t have to sign transactions every time they want to access them (due to dApp-level provisioning), low latency, high transaction throughput, and the ability to handle complex datasets efficiently. However, its use of the relational model for data storage is especially important.

What is a Relational Database?

A relational database is a data storage medium that stores records in relations. A record is a unit of data (such as a transaction or user account), and in the case of a relational database — it is stored in a table (otherwise called a ‘relation’). Several operations can be performed on said tables that aid the data analysis process. Below is an example of a relational database table ‘cryptoprices’, after utilizing an inner join query to conjoin the algorithm column of another table (the one called ‘cryptocharacteristics’) to it.

Below is a very simple example of how a relational database can be used to conjoin two different (one with prices, and the other with technical data) tables to help visualize patterns and relationships. One could also sort the resulting printout by market capitalization and show whether PoW or PoS coins are dominant.

‘cryptoprices’ contains cryptocurrency prices, and ‘cryptocharacteristics’ contains technical data about cryptocurrencies such as their consensus algorithm (the ‘algorithm’ column).

A PostgreSQL Inner Join Query

In a blockchain, records are usually stored in key-value pairs located in blocks. Key-value pairs look like something like this, using only three of the above records as examples (notice how the 8 records above look compared to the three below):

    name: 'Bitcoin',
    usdmarketcap: 130268904645,
    usdprice: 7209.53,
    name: 'EOS',
    usdmarketcap: 2474340998,
    usdprice: 2.63,
    name: 'Litecoin',
    usdmarketcap: 3014456177,
    usdprice: 47.31,

Each block is chained together by a hash of the previous block’s contents, and merkle trees may be utilized to ensure data consistency (and integrity), prevent tampering and deter hacking (note that blockchain designs vary). You want to be able to combine the data corruption prevention and security benefits of blockchain with the readability and analytical benefits of relational databases.

Why are Relational Databases Important?

There are multiple database management systems in use today. However, most companies use relational database management systems (RDBMS), and most of those systems utilize the structured query language (SQL). They use relational databases because the relational model is conducive to data analysis. 

You can sift through a relational database and find important patterns/connections rapidly and efficiently. This doesn’t mean that data research can’t be done on non-relational databases — what it means is that relational databases are particularly well suited for data analysis operations. Relational blockchain platforms are a new concept, which brings that kind of functionality (that conventional developers have had access to for years) to blockchain. 

Why Does it Matter that Chromia is Relational?

It is difficult for blockchain dApps to interface with conventional databases and off-chain software because they are substantially different and are struggling to converge. Chromia is a blockchain platform with a relational database built in. Its database query language is seamlessly integrated with its blockchain programming language Rell — and it looks very much like conventional programming languages!

If you’re familiar with common C-style languages (e.g. Java, C++, C#), you’ll catch onto Chromia quickly. This makes the developer onboarding process simple, which is imperative to getting more developers into blockchain. Rell could also be considered an object oriented blockchain programming language, as it uses classes in a manner similar to Java.

Chromia also has much in common with structured query languages (SQL) like MySQL and PostgreSQL. Here’s an example of the code to create a table in your database with the Rell programming language, it looks similar to Java as well (how you define a class): 

class cryptocurrency {
    pubkey: pubkey;
    symbol: text;
    usdprice: integer;

The PostgreSQL equivalent to that is:

CREATE TABLE cryptocurrencies (cryptoid int PRIMARY KEY, symbol varchar(20), usdprice int); 

There’s a little catch! If you’re writing a program that handles your data (which is almost always the case), a few additional steps are required, and that applies to most programming and scripting languages. Let’s assume for this example that you’re using Node.js. You’d have to:

  1. Write code to establish a connection to the database management system.
  2. Write more code to pass the CREATE query onto the database management system.
  3. Terminate your connection with the database management system (not always, though).

Here’s a Node.js example of what we tried to do above:

const client = new Client({
    user: 'nick',
    password: 'placeholder',
    host: 'localhost'
    database: 'cryptocurrencies',
    port: 5432


client.query("CREATE TABLE cryptocurrencies (cryptoid int PRIMARY KEY, symbol varchar(20), usdprice int)", (err, res) => 

The ability to handle your data without the legwork of managing your connection to the database management system will save time on development. The Rell programming language also offers benefits such as static typing to detect errors earlier and overflow protection. A statically-typed programming language is one in which variable types are known at compile time. For example: ‘usdprice’ was declared an integer in the example above, so it’s clear that it’s an integer.

Rell works by compiling your code down to an intermediary binary format, and Chromia nodes translate your Rell queries into SQL. Chromia is based on the Postchain framework, which uses PostgreSQL — one of the most widely used database management systems among enterprises under the hood. Rell queries will only slow down the dApp executing them, rather than the whole network.

While Rell is similar to SQL, it is up to seven times more compact. This is better for developers, as SQL is verbose. Chromia also has a browser-based editor called Rell IDE, and a node that you can use to try it out yourself — no installation required.

Two of Chromia’s largest competitors are Ethereum and EOS, which use key-value stores such as levelDB and MongoDB (optionally) respectively. Ethereum is a proof-of-work platform working to improve its scalability and EOS is designed to be a scalable alternative to Ethereum — However, neither of them are relational.

Share this article
Shareable URL
Prev Post

Games That Will Make You Feel At Home On Linux

Next Post

The Importance Of Choosing The Right Seal Materials

Leave a Reply

Read next
Subscribe to our newsletter
Get notified when new content is published