Skip to content

mustafamengutay/breezedb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

breezedb

C++20 MIT License

🌬️ BreezeDB: Minimal In-Memory Relational Database

BreezeDB is a lightweight, modern C++ in-memory relational database designed for learning, prototyping, and rapid experimentation. It features a simple SQL-like interface, modular architecture, and robust error handling.


🏗️ Architecture Overview

Component Responsibility
Database Manages all tables and orchestrates SQL statement execution
Table Stores schema and row data for each table
Row Represents a single record in a table
Parser Converts SQL-like strings into executable statement objects
Statement Abstract base for all SQL operations (CREATE, INSERT, SELECT, etc.)
  • All data is stored in memory (no persistence)
  • SQL commands are parsed and mapped to C++ objects
  • Supports basic relational operations, conditions, and inner joins

🧑‍💻 Software Design

  • Modular & Extensible: Each SQL command is implemented as a separate Statement class, making it easy to add new features.
  • Polymorphic Execution: All statements inherit from a common interface and are executed via a unified method.
  • Robust Error Handling: Invalid SQL or operations throw clear exceptions.
  • Test Coverage: Core functionality is covered with Catch2 unit tests.

⚙️ Implementation Highlights

  • Written in modern C++20
  • In-memory only (no disk persistence)
  • SQL-like syntax for ease of use
  • Supports WHERE, AND, OR, and INNER JOIN operations

🚀 Getting Started

Compile the main program from the src directory:

g++ -std=c++20 -I../include *.cpp statements/*.cpp -o main

# Then
./src/main

Run tests

g++ -std=c++20 -Wall -Wextra -Iinclude tests/test_breezedb.cpp src/Database.cpp src/Parser.cpp src/Row.cpp src/Table.cpp src/Condition.cpp src/statements/*.cpp -o tests/test_breezedb

# Then
./tests/test_breezedb
rm -rf build

# CMake
cmake -S . -B build
cmake --build build && ctest --test-dir build --output-on-failure

📋 Example SQL Commands

CREATE TABLE users (id int, name str, age int);
INSERT INTO users (id, name, age) VALUES (1, "Ali", 25), (2, "Veli", 30), (3, "Ayşe", 28);
SELECT * FROM users;
UPDATE users SET age = 26 WHERE name = "Ali";
SELECT * FROM users;
DELETE FROM users WHERE id = 2;
SELECT * FROM users;

-- CONDITIONS
SELECT * FROM users WHERE age >= 25;
SELECT * FROM users WHERE age <= 28;
SELECT * FROM users WHERE age > 20 AND age < 30;
SELECT * FROM users WHERE name != "Ali" OR age = 30;

-- INNER JOIN
CREATE TABLE users (id int, name str);
CREATE TABLE orders (id int, user_id int, amount int);

INSERT INTO users (id, name) VALUES (1, "Ali"), (2, "Veli");
INSERT INTO orders (id, user_id, amount) VALUES (1, 1, 100), (2, 1, 200), (3, 2, 300);

SELECT users.name, orders.amount FROM users INNER JOIN orders ON users.id = orders.user_id;

📦 Example Table Structure

id name age
1 Ali 25
2 Veli 30
3 Ayşe 28

📝 License

MIT License © 2025


About

BreezeDB is a relational, minimal in-memory database written in C++ | CITHN2012 @ TUM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages