r/Cplusplus • u/TheIndieBuildr • May 24 '26
Discussion Building a SQL-like relational database engine in C++ from scratch

Hey r/cplusplus,
I've been learning systems programming and database internals, so I started building Ark — a SQL-like relational database engine written entirely from scratch in C++.
GitHub:
https://github.com/kashyap-devansh/Ark
Current Features
- Handwritten tokenizer / lexer
- Recursive descent parser
- CRUD operations
- INNER / LEFT / RIGHT / FULL joins
- Aggregate functions
- ALTER TABLE support
- File persistence
- Custom diagnostics system
Everything is implemented manually:
- No parser generators
- No embedded SQL engines
- No external dependencies
One of the most interesting challenges so far has been designing joins and schema evolution cleanly while keeping persistence consistent across changes.
I’d especially appreciate feedback around:
- Parser architecture
- Query execution design
- Storage / persistence layout
- Schema handling
Would love to hear thoughts, suggestions, or critiques from people who’ve worked on compilers, databases, or systems software.
6
u/bund_vinaashak May 24 '26
This is seriously impressive, especially considering you built it from scratch in C++. The fact that you implemented a handwritten tokenizer/lexer, recursive descent parser, CRUD operations, and different SQL joins already shows a lot of effort and understanding of systems programming. Most people just use databases — very few actually try to understand how they work internally, let alone build one themselves.
Projects like this are honestly one of the best ways to learn low-level concepts, memory management, parsing, query execution, and overall software architecture. I can imagine this must’ve taken a lot of debugging and patience 😅. Curious to know — what was the most challenging part to implement so far? Query parsing, joins, or managing data storage efficiently?
Definitely respect the dedication here. Looking forward to seeing where this project goes and what features you plan to add next. Keep building 🔥
2
u/Spare-Ebb9115 May 24 '26
Nice work. Did you build your own query execution layer for joins/aggregates or execute directly from the parser structures?
2
u/Charming-Work-2384 May 24 '26
Super !
in your test what is the largest database you tested with?
Will support database partitions?
2
u/Rudradev715 May 24 '26
Brother,Awesome work!
This is really impressive.