In this project you will implement a relational database management system. More specifically, you will implement an RDBMS where the entire database is stored in a single file, similar to the popular SQLite system. The goal of this project is for you to understand how databases work internally, and to understand what happens “under the hood” when you run a SQL query.
The project is completed in three stages:
You will implement a series of functions to create and manipulate file-based B-Trees. The chidb file format is based on the SQLite format and, in fact, chidb files can be opened and manipulated using SQLite. This will show you how files are organized in a real RDBMS.
You will implement a database machine (DBM). In most RDBMS’s, SQL queries are compiled into instructions for a virtual machine (as opposed to being compiled down to x86 instructions). These virtual machines include instructions to seek keys in an index, access specific columns in a database record, etc. We provide you with the basic infrastructure of the DBM, but you must implement all the instructions in the DBM.
Once you have implemented the database machine, you will implement a SQL compiler. We provide you with a parser and lexer that will parse SQL queries and will provide an internal representation that is similar to relational algebra. You will need to take those representations, and translate them into DBM programs.
You will implement a query optimizer. You will improve your SQL compiler to apply a number of query optimization strategies.
The chidb documentation is divided into the following sections: