MiniDB is a lightweight, transactional, SQL-compliant database engine written in Go. Based on the LSM Tree (Log-Structured Merge Tree) architecture, it is designed for educational purposes to demonstrate core database internals including MVCC, WAL, compaction, and query execution.
- Storage Engine: LSM Tree (MemTable + SSTables) optimized for write-heavy workloads.
- Durability: Write-Ahead Logging (WAL) ensures data is never lost, even after a crash.
- Transactions: Full ACID support with Snapshot Isolation using Multi-Version Concurrency Control (MVCC).
- SQL Support: Custom parser and execution engine supporting
SELECT,INSERT, andWHEREclauses. - Indexing: Hash Index support for O(1) primary key lookups.
- Compaction: Background merging of SSTables to reclaim space and improve read performance.
- Interfaces: Interactive CLI (REPL) and TCP Server mode.
- Go 1.20 or higher
Clone the repository and build using Make:
git clone https://github.com/yourusername/minidb.git
cd minidb
make build1. Interactive Mode (REPL)
make runOr manually: ./minidb
Example Session:
minidb> HELP
minidb> SHOW TABLES
Tables:
users
(1 rows)
minidb> DESCRIBE users
Table: users
Column | Type
-------+-----
id | int
name | string
minidb> INSERT INTO users VALUES (1, 'Alice')
minidb> SELECT * FROM users WHERE id = 1
[1 Alice]2. Server Mode
make serverOr manually: ./minidb -server -port 3000
Run all tests:
make testDetailed documentation is available in the docs/ directory:
Run the comprehensive test suite to ensure everything is working:
go test ./...