![midoridblogo_readme](https://private-user-images.githubusercontent.com/1011868/277098228-3356dfb3-e62c-4019-a43e-afe1a25b457a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxMTAxMzUsIm5iZiI6MTczOTEwOTgzNSwicGF0aCI6Ii8xMDExODY4LzI3NzA5ODIyOC0zMzU2ZGZiMy1lNjJjLTQwMTktYTQzZS1hZmUxYTI1YjQ1N2EucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwOSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDlUMTQwMzU1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MDcyNjFjMmQ3NzhjYWE0ODllOThmZGIxODhlNWMwMjk5MjZiMjQzNTdlMThlMTNmNmYxZmFmYzc0ZGFhZWMxYiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.AUty6JHR9DEyutcYyQMLpXo2VstlyNn-uOKmuBWMTWk)
In-memory database written in C completely from scratch.
- Dependency Minimalism: It relies solely on
libc
andlibm
in runtime, ensuring easy integration and reducing external dependencies - Custom Implementation: Every component of MidoriDB has been crafted from the ground up - mostly because I wanted to learn about it really
- Small Footprint: approximately 200KB.
On ubuntu:
apt install bison flex libfl-dev
# if you want to build tests
apt install libcunit1-dev
To build it, just run:
make
make all
./build/tests/run_unit_tests
gcc -L<root_repo>/build/ \
-lmidoridb \
-Wl,-rpath <root_repo>/build/ \
-o your_code
#include <engine/query.h>
int main(void) {
struct database db = {0};
struct query_output *output;
if (database_open(&db) != MIDORIDB_OK)
return -1;
output = query_execute(&db, "SELECT "
" id_a, COUNT(*) "
"FROM "
" A INNER JOIN B "
" ON A.id_a = B.id_b "
"GROUP BY "
" id_a;");
if (output->status != ST_OK_WITH_RESULTS)
return -1;
while (query_cur_step(&output->results) == MIDORIDB_ROW) {
printf("id_a: %ld, count: %ld\n"
query_column_int64(&output->results, 0),
query_column_int64(&output->results, 1));
}
query_free(output);
database_close(&db);
return 0;
}
To make sure I won't lose focus on what I want this database to be able to do, I decided to write a list of features that I want to implement in the short to medium term.
- In-memory
- Parser (CREATE, SELECT, INSERT, UPDATE, DELETE)
- Recursive JOINs (INNER - more to come)
- Recursive expressions (INSERT)
- Locking [Granularity -> Table-level]
These are all the references that helped me a lot during the development of MidoriDB
Books:
- https://www.amazon.com/flex-bison-Text-Processing-Tools/dp/0596155972
- https://www.amazon.com/Database-Internals-Deep-Distributed-Systems/dp/1492040347
Courses: