A lightweight, file-based relational database management system (DBMS) written in C++ with a modern WPF GUI interface. This project demonstrates fundamental database concepts including SQL parsing, query execution, and data persistence using CSV file storage.
ITI-SQL Database Engine is an educational database system that implements core RDBMS functionality from scratch. The project consists of two main components:
The core engine is a command-line application written in C++ that:
- Parses and executes SQL-like commands
- Manages table creation, data manipulation, and queries
- Persists data to disk using CSV file format
- Provides a colorized console interface for direct interaction
A modern graphical user interface built with Windows Presentation Foundation (WPF) that:
- Provides a Visual Studio-inspired dark theme interface
- Launches and manages the C++ database engine as a subprocess
- Sends SQL commands to the engine via standard input
- Displays query results and engine output in real-time
- Includes keyboard shortcuts for improved productivity
- CREATE TABLE - Define new tables with typed columns and constraints
- INSERT INTO - Add new records to tables
- SELECT - Query data with support for column projection and WHERE clauses
- UPDATE - Modify existing records based on conditions
- DELETE - Remove records from tables
- DROP TABLE - Delete entire tables and their data
- INT - Integer values
- VARCHAR(n) - Variable-length strings with maximum length
- PRIMARY KEY - Unique identifier constraint
- NOT NULL - Non-nullable column constraint
- CSV-based file storage - Each table stored as a separate
.csvfile - Schema metadata - Column names, types, and constraints stored in file headers
- Automatic file management - Tables created/deleted as files on disk
- Engine lifecycle management - Start/stop the database engine
- Auto-start option - Automatically launch engine on application startup
- Command history - Navigate previous commands with arrow keys
- Syntax highlighting - Monospace font for SQL readability
- Output saving - Export console output to text files
- Keyboard shortcuts - F5 (start), Shift+F5 (stop), Ctrl+Enter (execute), Ctrl+S (save output)
┌─────────────────────────────────────────────────────────┐
│ Main Application │
│ (Db engine.cpp) │
└────────────────────┬────────────────────────────────────┘
│
▼
┌───────────────────────┐
│ Command Parser │
│ (main loop) │
└───────┬───────────────┘
│
┌────────────┼────────────┬──────────┬──────────┐
▼ ▼ ▼ ▼ ▼
┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐
│CREATE │ │SELECT │ │INSERT │ │UPDATE │ │DELETE │
│Module │ │Module │ │Module │ │Module │ │Module │
└───┬────┘ └───┬────┘ └───┬────┘ └───┬────┘ └───┬────┘
│ │ │ │ │
└───────────┴───────────┴───────────┴───────────┘
│
▼
┌─────────────────┐
│ Utils Module │
│ - File I/O │
│ - Data Parsing │
│ - Validation │
└────────┬────────┘
│
▼
┌─────────────────┐
│ File System │
│ (.csv files) │
└─────────────────┘
┌──────────────────────────────────────────────────────────┐
│ WPF GUI Application │
│ (MainWindow.xaml.cs) │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Input Panel │ │ Output Panel │ │ Control Bar │ │
│ │ (SQL Editor) │ │ (Console) │ │ (Start/Stop) │ │
│ └──────┬───────┘ └──────▲───────┘ └──────┬───────┘ │
│ │ │ │ │
└─────────┼──────────────────┼──────────────────┼──────────┘
│ │ │
│ SQL Commands │ Output Stream │ Process Control
│ (stdin) │ (stdout/stderr) │ (Start/Kill)
│ │ │
▼ │ ▼
┌─────────────────────────────────────────────────────────┐
│ C++ Database Engine Process │
│ (Db engine.exe) │
└─────────────────────────────────────────────────────────┘
Communication Flow:
- User types SQL command in GUI input box
- GUI sends command to engine via
StandardInputstream - Engine parses and executes the command
- Engine writes results to
StandardOutput - GUI captures output and displays in console panel
- Process repeats for each command
Db-engine/
├── Db engine/ # C++ Database Engine Source
│ ├── Db engine.cpp # Main entry point and command loop
│ ├── Create.cpp/h # CREATE TABLE implementation
│ ├── Select.cpp/h # SELECT query implementation
│ ├── Insert.cpp/h # INSERT INTO implementation
│ ├── Update.cpp/h # UPDATE statement implementation
│ ├── Delete.cpp/h # DELETE statement implementation
│ ├── Drop.cpp/h # DROP TABLE implementation
│ ├── Helper.cpp/h # Help command and documentation
│ ├── Utils.cpp/h # Utility functions and data structures
│ └── Db engine.vcxproj # Visual Studio C++ project file
│
├── GuiApp/ # WPF GUI Application
│ ├── MainWindow.xaml # GUI layout and styling
│ ├── MainWindow.xaml.cs # GUI logic and engine communication
│ ├── App.xaml # Application resources
│ ├── App.xaml.cs # Application entry point
│ ├── GuiApp.csproj # Visual Studio C# project file
│ └── Properties/ # Assembly metadata
│
├── x64/Debug/ # Build output directory
│ ├── Db engine.exe # Compiled database engine
│ └── *.csv # Database table files
│
└── Db engine.sln # Visual Studio solution file
| File | Purpose |
|---|---|
Db engine.cpp |
Main application loop, command routing, and user interface |
Utils.h/cpp |
Core data structures (Column, Row, Table, TableData), file I/O, string utilities |
Create.h/cpp |
Parses CREATE TABLE syntax, validates schema, creates CSV files |
Select.h/cpp |
Implements SELECT queries with column projection and WHERE filtering |
Insert.h/cpp |
Handles INSERT INTO statements, validates data types |
Update.h/cpp |
Processes UPDATE statements with WHERE conditions |
Delete.h/cpp |
Executes DELETE statements with conditional filtering |
Drop.h/cpp |
Removes table files from disk |
Helper.h/cpp |
Displays available commands and syntax examples |
MainWindow.xaml |
WPF UI layout with modern dark theme styling |
MainWindow.xaml.cs |
Process management, I/O redirection, event handlers |
- Language: C++17
- Compiler: MSVC (Visual Studio 2019/2022)
- Standard Library: STL (iostream, fstream, string, vector)
- Platform: Windows (uses Windows Console API for colors)
- Framework: .NET Framework 4.7.2+
- UI Technology: Windows Presentation Foundation (WPF)
- Language: C# 7.0+
- Design Pattern: MVVM-inspired architecture
- IDE: Visual Studio 2019/2022
- Build System: MSBuild
- Version Control: Git
Tables are stored as CSV files with a special header format:
ID:INT,NAME:VARCHAR,AGE:INT
1,John Doe,30
2,Jane Smith,25Header Format: ColumnName:DataType[,ColumnName:DataType...]
-
Input Reading
- User enters SQL command
- Command converted to uppercase for case-insensitive parsing
- Whitespace normalized
-
Command Recognition
- Pattern matching against known SQL keywords
- Route to appropriate handler module
-
Query Parsing
- Extract table names, column names, values
- Validate syntax and semantics
- Build internal data structures
-
Execution
- Read table metadata from CSV header
- Load/modify data rows as needed
- Apply WHERE clause filtering
- Validate constraints (PRIMARY KEY, NOT NULL)
-
Result Output
- Format results in tabular format
- Display to console with color coding
- Write changes back to CSV files
SELECT NAME, AGE FROM Employee WHERE ID=1
↓
Parse Query
↓
Read Employee.csv
↓
Load all rows into memory
↓
Filter rows where ID=1
↓
Project NAME and AGE columns
↓
Display formatted table
Current Implementation: No indexing (full table scans)
Note: This is an educational project. Production databases use B-trees, hash indexes, and other data structures for efficient lookups.
- Start Engine Button - Launches
Db engine.exeas subprocess - Stop Engine Button - Terminates the running engine process
- Auto-start Checkbox - Enable automatic engine startup
- Status Indicator - Visual feedback (green=running, red=stopped)
- Displays all engine output in real-time
- Read-only monospace text area
- Supports scrolling and text selection
- Save button to export output to file
- Multi-line text editor for SQL commands
- Syntax-friendly monospace font
- Command history navigation (↑/↓ arrows)
- Execute button sends command to engine
- Shows path to
Db engine.exe - Displays current application state
| Action | Keyboard Shortcut | Description |
|---|---|---|
| Start Engine | F5 |
Launch database engine process |
| Stop Engine | Shift+F5 |
Terminate engine process |
| Execute Command | Ctrl+Enter |
Send SQL command to engine |
| Clear Input | Ctrl+L |
Clear the input text box |
| Save Output | Ctrl+S |
Export console output to file |
| Previous Command | ↑ |
Navigate to previous command in history |
| Next Command | ↓ |
Navigate to next command in history |
-
User Input
- User types SQL command in input box
- Presses Execute button or
Ctrl+Enter
-
Command Transmission
- GUI writes command to engine's
StandardInputstream - Command appended with newline character
- GUI writes command to engine's
-
Engine Processing
- Engine reads from stdin
- Executes command
- Writes results to stdout
-
Result Display
- GUI asynchronously reads from engine's
StandardOutput - Text appended to output console in real-time
- Auto-scrolls to show latest output
- GUI asynchronously reads from engine's
-
Error Handling
- Errors written to stderr by engine
- GUI captures and displays errors in red (if colorized)
- Operating System: Windows 10/11
- Visual Studio: 2019 or 2022
- Workloads Required:
- Desktop development with C++
- .NET desktop development
-
Clone the repository
git clone <repository-url> cd Db-engine
-
Open the solution
- Double-click
Db engine.sln - Visual Studio will load both projects
- Double-click
-
Build the C++ Engine
- Right-click
Db engineproject → Build - Output:
x64/Debug/Db engine.exe
- Right-click
-
Build the GUI Application
- Right-click
GuiAppproject → Build - Output:
GuiApp/bin/Debug/GuiApp.exe
- Right-click
-
Set startup project (optional)
- Right-click
GuiApp→ Set as Startup Project - Press
F5to run
- Right-click
# Navigate to project directory
cd "C:\ITI\Db-engine"
# Build C++ engine
msbuild "Db engine\Db engine.vcxproj" /p:Configuration=Debug /p:Platform=x64
# Build GUI application
msbuild "GuiApp\GuiApp.csproj" /p:Configuration=Debugcd GuiApp\bin\Debug
.\GuiApp.exe- Click "Start Engine" button
- GUI will automatically locate and launch
Db engine.exe
cd x64\Debug
.\Db engine.exe- Provides direct command-line interface
- No GUI required
CREATE TABLE Employee(ID INT Primary Key, NAME VARCHAR(50) NOT NULL, AGE INT)Output:
Table 'Employee' created successfully.
File Created: Employee.csv
ID:INT,NAME:VARCHAR,AGE:INTINSERT INTO Employee VALUES (1, 'John Doe', 30)
INSERT INTO Employee VALUES (2, 'Jane Smith', 25)
INSERT INTO Employee VALUES (3, 'Bob Johnson', 35)Output:
1 row inserted successfully.
1 row inserted successfully.
1 row inserted successfully.
SELECT * FROM EmployeeOutput:
+----+-------------+-----+
| ID | NAME | AGE |
+----+-------------+-----+
| 1 | John Doe | 30 |
| 2 | Jane Smith | 25 |
| 3 | Bob Johnson | 35 |
+----+-------------+-----+
3 rows selected.
SELECT NAME, AGE FROM EmployeeOutput:
+-------------+-----+
| NAME | AGE |
+-------------+-----+
| John Doe | 30 |
| Jane Smith | 25 |
| Bob Johnson | 35 |
+-------------+-----+
SELECT * FROM Employee WHERE ID=2Output:
+----+------------+-----+
| ID | NAME | AGE |
+----+------------+-----+
| 2 | Jane Smith | 25 |
+----+------------+-----+
1 row selected.
UPDATE Employee SET AGE=26 WHERE ID=2Output:
1 row updated successfully.
DELETE FROM Employee WHERE ID=3Output:
1 row deleted successfully.
DROP TABLE EmployeeOutput:
Table 'Employee' dropped successfully.
File Deleted: Employee.csv removed from disk
HELPOutput:
Available Commands:
===================
1. CREATE TABLE
Syntax: CREATE TABLE table_name (col1 type, col2 type, ...)
Example: CREATE TABLE Employee(ID INT Primary Key, NAME VARCHAR(50) NOT NULL)
2. SELECT
Syntax: SELECT * FROM table_name
Syntax: SELECT col1, col2 FROM table_name
Syntax: SELECT * FROM table_name WHERE col=val
3. UPDATE
Syntax: UPDATE table_name SET col=val WHERE col=val
4. DROP TABLE
Syntax: DROP TABLE table_name
5. HELP
Syntax: HELP
Description: Shows this help message.
6. EXIT / QUIT
Description: Exits the application.
-
No Transaction Support
- No ACID guarantees
- No rollback capability
- Changes are immediately persisted
-
Limited Data Types
- Only INT and VARCHAR supported
- No DATE, FLOAT, BOOLEAN, or BLOB types
-
No Indexing
- All queries perform full table scans
- Performance degrades with large datasets
-
Simple WHERE Clauses
- Only equality comparisons (
col=val) - No AND/OR operators
- No comparison operators (
<,>,<=,>=,!=)
- Only equality comparisons (
-
No JOIN Operations
- Cannot query multiple tables
- No foreign key relationships
-
No Aggregation Functions
- No COUNT, SUM, AVG, MIN, MAX
- No GROUP BY or HAVING clauses
-
No Subqueries
- Cannot nest SELECT statements
-
Case Sensitivity
- Table and column names are case-sensitive in file system
- SQL keywords are case-insensitive
-
Windows Only
- Uses Windows Console API for colors
- WPF GUI requires Windows OS
-
Single User
- No concurrent access control
- No network/client-server architecture
- File Encoding: UTF-8 for CSV files
- CSV Delimiter: Comma (
,) - Line Endings: Windows CRLF (
\r\n) - Engine Location: GUI searches for
Db engine.exein../x64/Debug/relative to GUI executable - Working Directory: CSV files created in engine's working directory
-
Advanced Query Features
- JOIN operations (INNER, LEFT, RIGHT, FULL)
- Aggregation functions (COUNT, SUM, AVG, MIN, MAX)
- GROUP BY and HAVING clauses
- ORDER BY sorting
- LIMIT and OFFSET pagination
- Subqueries and nested SELECT
-
Data Types & Constraints
- Additional data types (FLOAT, DATE, BOOLEAN, TEXT)
- FOREIGN KEY constraints
- UNIQUE constraints
- CHECK constraints
- DEFAULT values
- AUTO_INCREMENT for primary keys
-
Performance Optimizations
- B-tree indexing for faster lookups
- Query optimization and execution planning
- Caching frequently accessed tables
- Lazy loading for large datasets
-
Transaction Support
- BEGIN TRANSACTION, COMMIT, ROLLBACK
- ACID compliance
- Write-ahead logging (WAL)
- Crash recovery
-
Advanced WHERE Clauses
- Comparison operators (
<,>,<=,>=,!=) - Logical operators (AND, OR, NOT)
- LIKE pattern matching
- IN and BETWEEN operators
- NULL checks (IS NULL, IS NOT NULL)
- Comparison operators (
-
Storage Improvements
- Binary storage format for efficiency
- Compression for large tables
- Page-based storage management
-
GUI Enhancements
- Syntax highlighting for SQL
- Auto-completion for table/column names
- Visual query builder
- Table schema viewer
- Export results to CSV/JSON
- Dark/light theme toggle
-
Cross-Platform Support
- Linux and macOS compatibility
- Cross-platform GUI (Qt or Electron)
-
Multi-User Support
- Client-server architecture
- Network protocol (TCP/IP)
- User authentication and authorization
- Concurrent access control (locking)
-
Developer Tools
- Unit tests for all modules
- Integration tests for SQL queries
- Benchmarking suite
- Documentation generator
We welcome contributions from the community! Here's how you can help:
-
Fork the repository
git clone https://github.com/yourusername/Db-engine.git cd Db-engine -
Create a feature branch
git checkout -b feature/your-feature-name
-
Make your changes
- Follow existing code style and conventions
- Add comments for complex logic
- Update documentation as needed
-
Test your changes
- Build both C++ and C# projects
- Test all affected SQL commands
- Verify GUI functionality
-
Commit your changes
git add . git commit -m "Add: Brief description of your changes"
-
Push to your fork
git push origin feature/your-feature-name
-
Create a Pull Request
- Describe your changes in detail
- Reference any related issues
- Wait for code review
- Use camelCase for function names
- Use PascalCase for class/struct names
- Use snake_case for variables (optional)
- Indent with 4 spaces (no tabs)
- Add header guards to all
.hfiles - Include comments for non-obvious logic
- Follow Microsoft C# Coding Conventions
- Use PascalCase for public members
- Use camelCase for private fields (prefix with
_) - Use async/await for asynchronous operations
- Add XML documentation comments for public APIs
- 🐛 Bug Fixes - Report or fix issues
- ✨ New Features - Implement items from Future Improvements
- 📝 Documentation - Improve README, add code comments
- 🧪 Testing - Write unit/integration tests
- 🎨 UI/UX - Enhance GUI design and usability
- ⚡ Performance - Optimize query execution
This project is licensed under the MIT License.
MIT License
Copyright (c) 2025 ITI-SQL Database Engine Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- Issues: Report bugs or request features via GitHub Issues
- Discussions: Join conversations in GitHub Discussions
- Email: your.email@example.com
- Inspired by educational database projects and SQL tutorials
- Built as a learning project to understand DBMS internals
- Thanks to the open-source community for tools and libraries
- Database System Concepts - Comprehensive DBMS textbook
- SQLite Architecture - Real-world database design
- How Does a Database Work? - Build a database from scratch
- SQLite - Lightweight SQL database engine
- TinySQL - Educational SQL database in Go
- SimpleDB - Java-based educational DBMS
Made with ❤️ for learning and education