Giter Club home page Giter Club logo

midoridb's Introduction

MidoriDB

Unit Tests

midoridblogo_readme

In-memory database written in C completely from scratch.

Features

  • Dependency Minimalism: It relies solely on libc and libm 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.

Build

On ubuntu:

apt install bison flex libfl-dev

# if you want to build tests
apt install libcunit1-dev

To build it, just run:

make

Running tests

make all
./build/tests/run_unit_tests

Linking shared-object with your executable

gcc  -L<root_repo>/build/               \
        -lmidoridb                      \
        -Wl,-rpath <root_repo>/build/	\
        -o your_code

Example

#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;
}

Wishlist

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]

References

These are all the references that helped me a lot during the development of MidoriDB

Books:

Courses:

midoridb's People

Contributors

paulomigalmeida avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

linuxperia

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.