SimDB is a lightweight file-based database system written in C++, supporting basic SQL operations like CREATE TABLE, INSERT, SELECT, and DELETE. It utilizes binary file storage and indexing with B-Trees (future feature) for efficient data retrieval.
✔️ Basic SQL Operations (CREATE, INSERT, SELECT, DELETE)
✔️ File-Based Storage (Data stored in binary files)
✔️ Indexing with Hash Index (Current Indexing)
✔️ Indexing with B-Trees (Upcoming feature)
✔️ SQL Query Parser
✔️ Docker Support for easy deployment
SimpleDB/
│── src/
│ ├── main.cpp # Entry point
│ ├── storage.cpp # Handles file-based storage
│ ├── btree.cpp # B-Tree indexing implementation
│ ├── parser.cpp # SQL query parsing
│ ├── executor.cpp # Executes parsed queries
│── include/
│ ├── storage.h
│ ├── btree.h
│ ├── parser.h
│ ├── executor.h
│── data/ # Stores database files
│── tests/ # Unit tests
│── CMakeLists.txt # Build configuration
│── README.md # Project documentation
- C++ (GCC/Clang/MSVC)
- CMake
- Docker (Optional for containerized execution)
Run the following commands to build and compile:
mkdir build && cd build
cmake ..
make
./SimDB🔹 Build the Docker Image
docker build -t simdb .Run the Container
docker run -it simdb🔹 Inside the Container shell
cd build
./SimDB- Parses SQL queries into structured commands.
- Example:
→
INSERT INTO employees VALUES (John, 25, 5000)
{ Table: employees, Values: [John, 25, 5000] }
- Calls Storage functions based on parsed queries.
- Example:
parseInsert(query) → executeInsert(tableName, values)
- Stores records in binary files.
- Uses indexed offsets for fast retrieval.
- Uses indexed offsets for fast retrieval as HashMap Index.
- Will improve search performance using a B-Tree index.
- Problem: Parsing SQL queries dynamically while supporting different formats.
- Solution: Implemented a string tokenizer & condition parser to extract and process queries efficiently.
- Problem: Storing data in a binary file while allowing fast lookups.
- Solution: Used an index file to store offsets for quick access.
- Problem: Deleting records without breaking indexing order.
- Solution: Implemented a record swapping mechanism to maintain sequential integrity.