Skip to content

rayzhuca/eggshell-db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Screenshot 2024-02-18 at 4 57 57 PM eggshell db

workflow badge

Relational database model built in C++, written as a learning project.

Eggshell could support concurrent read and write operations. It utilizes a readers-writer lock.

It could also support atomicity, as previous pages are logged before they are modified.

The project includes two basic SQL commands,

INSERT INTO table_name VALUES (value1, value2, ...);
SELECT column1, column2 FROM table_name;

Architecture

The library is broken down into two sections, compiler and storage, where the compiler composes inputs into commands and storage is responsible for storing data.

toydb architecture (1)

Usage

Must have C++-17 installed along with CMake.

Before the first build, run

cmake -S . -B ./build 

To build, run

cmake --build build

To run the REPL, first create an empty file, e.g., touch example.db, then run

build/repl example.db

Future features

Some features to be implemented in the future are

  • JOIN clauses
  • Immutable B+ tree for complete atomic transactions
  • Distributed database
  • Error system (for now, we are just using exit on failure)

Tests

eggshell uses Google Test, which is simple to configure and run. To test, run the following command after building:

ctest --test-dir build

or alternatively,

build && ctest

To run a specific test, do

build/{TEST_FILE_NAME}

If intellisense is having trouble finding gtest, make sure to add the gtest onto the include path. For VSCode, c_cpp_properties.json should have something like the following

{
"configurations": [
        {
            "includePath": [
                "${workspaceFolder}/_deps/googletest-src/googletest/include"
            ],
        }
    ]
}

Resources and credits

As someone who had no previous knowledge of databases, I have used numerous resources for this project that I would love to share.

Good project examples

Let's Build a Simple Database (C)

Build Your Own Database From Scratch (Go)

toyDB (Rust)

General database theory

CMU Database Group

Parser

Cornell Introduction to Compiler

About

Relational database model built in C++

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published