SQLite for ERIS block storage

SQLite is a popular embedded database. This document specifies a portable schema for storing blocks of ERIS encoded content into an SQLite database. This allows SQLite datbases to be used as portable, cross-platform and cross-implementation formats for storing and exchanging ERIS encoded content (see also SQLite As An Application File Format).

An SQLite database is well-suited for transferring ERIS encoded content over USB sticks or other portable media. Unlike the CBOR serialization an SQLite database allows efficient random-access without additional indexing or decoding.

Schema

Blocks of ERIS encoded content should be stored in a table eris_block that has 3 columns:

An SQL statement that creates the table and an index for accessing blocks by their reference:

CREATE TABLE IF NOT EXISTS eris_block (
              block_id INTEGER PRIMARY KEY,
              ref BLOB UNIQUE,
              block BLOB
);

Implementation Notes

Extensibility

Applications and implementations may define other tables in the SQLite database. For example tables may be used for application specific configuration or block management.

When referencing blocks in the eris_block table, the block_id columns should be used as foreign key. This is much more efficient than using the ref column.

Note that it is necessary to define the block_id column instead of just using the rowid column as SQLite does not allow the rowid to be a parent key (see the SQLite documentation on foreign key support).

Transactions

Performance can be increased by grouping block insertions into transactions (see the SQLite documentation on Transactions).

Implementations

The Oebstly block storage tool implements the SQLite schema as described above.