How eclipsu/minidb works
MiniDB is a file-backed, in-memory database with a SQL prompt. The primary workflow is prompt input → tokenization → parsing into a statement → database execution → formatted result; table operations use a per-table B-Tree, while dot commands manage CSV persistence. The README also documents table listing, save/load, and exit handling. The excerpts establish the prompt orchestration, parsing and execution behavior, and storage mechanics; some executor-to-tree and database-to-storage links are supported by the documented interfaces rather than complete call-site excerpts.
Main entry points: main.cpp Prompt and commands · executor.cpp Database executor · btree.h B-Tree interface · storage.cpp CSV table storage
Components 15
SQL interface
- Prompt and commands
src/main.cpp - SQL tokenizer
src/tokenizer.cpp - SQL parser
src/parser.cpp - Statement model
src/statement.h
Database execution
- Database executor
src/executor.cpp - Table catalog
src/executor.h - Query and row operations
src/executor.cpp - Result formatting
src/executor.cpp
B-Tree index
- B-Tree interface
src/btree.h - B-Tree insertion
src/btree_insert.cpp - B-Tree deletion
src/btree_remove.cpp - B-Tree traversal and checks
src/btree.cpp
CSV persistence
- CSV table storage
src/storage.cpp - Table CSV files
Other components
- SQL user
Connections 20
- SQL user → Prompt and commands: enters commands
README.md - Prompt and commands → SQL tokenizer: tokenizes SQL
src/main.cpp - Prompt and commands → SQL parser: parses tokens
src/main.cpp - SQL parser → Statement model: builds statement
src/parser.cpp - Prompt and commands → Database executor: executes statement
src/main.cpp - Database executor → Statement model: consumes statement
- Database executor → Table catalog: manages tables
src/executor.h - Database executor → Query and row operations: dispatches operations
src/executor.cpp - Prompt and commands → Result formatting: formats response
src/main.cpp - Database executor → Result formatting: formats results
src/executor.cpp - Query and row operations → B-Tree interface: uses row index
- B-Tree interface → B-Tree insertion: inserts via
src/btree.h - B-Tree interface → B-Tree deletion: removes via
src/btree.h - B-Tree interface → B-Tree traversal and checks: delegates core
src/btree.h - Database executor → CSV table storage: saves and loads
- CSV table storage → Table CSV files: reads and writes
src/storage.cpp - CSV table storage → B-Tree interface: traverses and populates
src/storage.cpp - Prompt and commands → Table catalog: lists tables
src/main.cpp - Prompt and commands → CSV table storage: routes dot commands
src/main.cpp - Prompt and commands → Database executor: checks exit changes
src/main.cpp