Skip to content

🌳 An in-process DBMS that implements a self-contained, minimal configuration SQL database engine!

Notifications You must be signed in to change notification settings

yash-chad/YourSQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Logo

YourSQL!

An in-process DBMS that implements a self-contained, minimal-configuration, SQL database engine!
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Contributing
  4. Developed with ❤️ by

About The Project ✅

As a developer we use databases all the time, but they were always a black box for me. This was an attempt to actually understand databases, how they work internally and many more things!

Here's what we learnt/explored during the course of the project: 😄

  • What data structures are used by databases internally? and Why?
  • What format is data saved in?
  • How do databases process queries efficiently?
  • How are indexes formatted?
  • When does data move from memory to disk?

In short, how do databases work!

Working 💻

  • Compile the db.cpp file.

    Working 1

  • Enter the name of database during runtime. If the database already exists then it will load the file or else it will create a new file.

  • Insert Clause

    INSERT id, username, email;

    Working 2 Note : If the query syntax is not followed it throws a syntax error. Note: The column “id” is the primary key and therefore has to be unique. If the id is repeated the database will throw an error. Working 3

  • Select Clause
    To select all rows in a table :

    SELECT;

    Working 7

    To query a particular row/attribute :

    SELECT *column*  WHERE *column* *column-value*;

    Working 4

  • Update Clause

    Updates a particular column value inside a row in the table.

     UPDATE id column_name new_value;;

    Working 5

  • Exit Statement

    Closes the connection to the database and writes the updates(if any) to the database file. Working 6

Built With 🔨

The entire project was written in C++ for performing fast and efficient database queries.

Architecture 👷

The entire architecture of a DBMS is broken down into 4 major parts:

  1. The core
  2. SQL Compiler
  3. Backend
  4. Accessories

Architecture

1. The core

  • The Core consists of Interface, SQL Command Processor and Virtual Machine.

  • Interface is a medium by which the user will interact with the database through SQL queries.

  • SQL Command Processor redirects the query to the SQL compiler

  • Virtual machines interact with the core/backend of the database system.

2. SQL Compiler

  • The SQL Compiler consists of Tokenizer, Parser and Code Generator.
  • Tokenizer breaks the inputted SQL query into tokens and forwards it to the parser.
  • Parser assigns meaning to tokens based on their context and assembles them into a parse tree. It checks the correctness of the syntax, if correct then it redirects/calls the routines that are expected to be performed.
  • Code Generator runs to analyze the parse tree and generate bytecode that performs the work of the SQL statement.

3. Backend

  • The Backend consists of B+ Trees, Pager and OS Interface.
  • B+ Trees is the internal data structure that will be used to store the pages inside the database.
  • Pager: Every table is broken down into pages and internally each page is made up of rows.

Table_Page_Row_Architecture

A row is nothing but a database entry. The pager does the function of breaking down the rows into pages, gives the page number from the row number, etc.

  • OS interface handles the task of reading/writing data from the database file stored in the system.

4. Accessories

  • The Accessories consists of Utilities and Test Code.
  • Utilities: Memory allocation, caseless string comparison routines, portable text-to-number and conversion routines are included under utilities. Symbol tables used by the parser are maintained by hash tables in utilities.

Getting Started 💥

To get a local copy up and running follow these simple example steps:

Prerequisites

To get started you need to have G++ compiler installed on your machine. You can download it from Here.

Installation

  1. Clone the repo
    git clone https://github.com/yash-chad/YourSQL.git
  2. Compile the source file
    g++ db.cpp
  3. Run the generated execulatbe file db.exe.
    ./a.exe db.ysql
    Note : You need to mention the name of the database file you wish to use. The file will get created if it does not already exists.

Contributing 🤝

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Developed with ❤️ by

Yash Chachad - Github - chachadyash786@gmail.com

Rutu Gaglani - Github - rutugaglani@gmail.com

Sharayu Bokde - Github - bokde.sharayu@gmail.com

About

🌳 An in-process DBMS that implements a self-contained, minimal configuration SQL database engine!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages