Code Monkey home page Code Monkey logo

simple-database's Introduction

Simple Database

A self-taught project exploring database design using C with Catch2 testing framework.

Still need lots of refactor and performance optimization

Support Command

All Support commands: 
    help: 
    exit: 
    create: 
        Create sub-commands: 
            - database <database name> 
            - table <table name> (<column name> <column type> ...) 
    use: 
        <database name> 
    delete: 
        <database name> 
    select: 
        select <column_names> from <table_name> (where <condition> ...)
    insert:
        insert <table_name> values <value1,value2,value3,...>

Prerequisite

  • Docker

Usage

0. Create environment

  1. Build Docker Image
./scripts/build_docker_image.sh
  1. Run Docker Container
./scripts/run_docker_container.sh
  1. Build Project (compile with 8 cores)
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release -- -j 8
  1. Execute
./simple_database

1. Create a database

create database test_db

Result:

create database test_db
Create database at: ../DB_DATA/test_db/test_db.json 

2. Use database

use test_db

Results:

use test_db
Using database: test_db 

3. Create table

create table test_table name STRING age INT height FLOAT

  • with column name name, age, height

Results:

create table test_table name STRING age INT height FLOAT
Create table at: ../DB_DATA/test_db/test_table.csv 

4. Insert data

  • insert test_table values John 30 170
  • insert test_table values Jane 25 165
  • insert test_table values Alice 28 180
  • insert test_table values Bob 31 173
  • insert test_table values Charlie 29 160

5. Query data

select name,age from test_table where age < 29 and ( name = Jane or name = Alice )

Results:

name,age
Jane,25
Alice,28

6. Delete database

delete database test_db

Results:

Delete database: ../DB_DATA/test_db/test_db.json 
Delete table: ../DB_DATA/test_db/test_table.csv 

7. Exit

exit

Results:

Bye Bye 

Tests

./tests/tests_run

simple-database's People

Contributors

armcortex avatar

Stargazers

Hao avatar

Watchers

 avatar

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.