MiniDB is a compact relational database engine written in C. It ships as a single CLI binary with a SQL shell, persistent on-disk storage, catalog metadata, primary and secondary indexes, transactions, and write-ahead logging.
Current version: 0.1.2
- Persistent database directory under
mydb/ - SQL shell with parser, binder, planner, and executor layers
INTandTEXTcolumn typesCREATE TABLE,INSERT,SELECT,UPDATE, andDELETECREATE INDEXandDROP INDEXPRIMARY KEYandNOT NULLconstraints- Comparison predicates with
=,!=,>,<,>=, and<= - Primary-key B+ tree indexes
- Secondary indexes
- Catalog persistence
- Write-ahead log recovery path
- CI-backed checks with formatting, static analysis, unit tests, and sanitizers
Download a binary release for your platform, extract it, and run the installer:
tar -xzf MiniDB-0.1.2-<system>-<machine>.tar.gz
cd MiniDB-0.1.2-<system>-<machine>
./install.sh
MiniDB --versionBy default, the installer copies MiniDB to /usr/local/bin. To install
without elevated permissions, use a user-local prefix:
PREFIX="$HOME/.local" ./install.shMake sure $HOME/.local/bin is on your PATH when using a custom prefix.
Requirements:
- C11 compiler such as
gccorclang make
Build and run from a source checkout:
make
./MiniDBInstall from source:
make install
MiniDB --versionUse a custom install prefix when needed:
make install PREFIX="$HOME/.local"Uninstall from the same prefix:
make uninstall PREFIX="$HOME/.local"Start the shell:
MiniDBor, from an uninstalled source checkout:
make runExample session:
CREATE TABLE users (id INT PRIMARY KEY, name TEXT NOT NULL, age INT);
INSERT INTO users VALUES (1, "Finn", 20);
INSERT INTO users VALUES (2, "Alex", 21);
SELECT * FROM users;
SELECT name, age FROM users WHERE id = 1;
UPDATE users SET age = 22 WHERE name = "Alex";
DELETE FROM users WHERE id = 1;
.tables
.schema users
.exitMiniDB currently accepts one SQL statement per input line. SQL statements end with a semicolon. Shell commands start with a dot and do not need a semicolon.
CREATE TABLE table_name (
column_name INT [PRIMARY KEY] [NOT NULL],
column_name TEXT [NOT NULL]
);
CREATE INDEX index_name ON table_name (column_name [, column_name ...]);
DROP INDEX index_name;
INSERT INTO table_name VALUES (1, "text");
SELECT * FROM table_name;
SELECT column_name [, column_name ...] FROM table_name
[WHERE column_name = 1];
DELETE FROM table_name [WHERE column_name != "text"];
UPDATE table_name SET column_name = value
[WHERE column_name >= value];Supported shell commands:
.help
.exit
.tables
.schema <table>
Run the full local verification suite:
make checkThis runs:
make fmt-checkmake analyzemake testmake test-asan
Run only the unit suite:
make testCreate source and binary release archives:
make releaseThis runs make check, then writes:
dist/MiniDB-0.1.2.tar.gz
dist/MiniDB-0.1.2-<system>-<machine>.tar.gz
Create only the source archive:
make distCreate only the binary archive:
make packageRemove generated release artifacts:
make clean-distThe default database path is mydb/.
mydb/
catalog.db
minidb.wal
tables/
table_name.tbl
indexes/
table_name_pk.btree
index_name.sidx
Runtime database files are local state and should not be committed.
MiniDB is licensed under the MIT License.