A custom-built relational Database Management System (DBMS) written in Java. This project implements the core components of a database engine from scratch, focusing on low-level memory management, disk paging, and query execution operators.
This engine simulates the internal behavior of systems like PostgreSQL or MySQL. Unlike high-level SQL applications, this project handles the physical storage of data, buffer pooling, and the algorithmic implementation of relational operators (Selection, Projection, Join).
Key Technical Features:
- Page-Oriented Storage: Data is stored in binary pages (fixed size) managed directly on the disk.
- Buffer Management: Implementation of a Frame Pool with replacement policies (LRU/Clock) to optimize I/O cost.
- Query Execution Engine: Implementation of Volcan-style iterators (
IRecordIterator) for pipelined query processing. - Heap Files: Management of free slots and record serialization.
The codebase follows a strict layered architecture, separating physical storage from logical query processing.
graph TD;
A["Client / CLI"] --> B["requete (DBManager)"];
B --> C["relationnel (Relations & Records)"];
C --> D["buffer (BufferManager)"];
D --> E["espaceDisque (DiskManager)"];
E --> F[("Disk Storage")];
Based on the src/main/java structure:
-
espaceDisque/(Disk Manager Layer)- Handles the physical allocation/deallocation of Pages (
PageId,DiskManager). - Manages persistent storage in
.dbfiles. - Implements low-level iterators (
PageDirectoryIterator).
- Handles the physical allocation/deallocation of Pages (
-
buffer/(Buffer Management Layer)BufferManager: Acts as the cache between Disk and Memory. It manages "Frames" and handles page pinning/unpinning to minimize expensive disk access.
-
relationnel/(Data Structure Layer)- Defines the schema and data representation.
Relation: Represents a table schema.Record: Handles byte-level serialization/deserialization of tuples.
-
requete/(Query Processor Layer)DBManager: The main entry point for executing queries.Condition: EvaluatesWHEREclauses (filters).ProjectOperator/JoinOperator: Implementation of relational algebra operators.
-
test/(Unit Testing)- Comprehensive testing suite for each layer (
DiskManagerTests,RelationTest, etc.) ensuring component reliability.
- Comprehensive testing suite for each layer (
This project was developed as part of the Computer Science curriculum at Université Paris Cité.
The engine supports a subset of SQL-like commands handled by the DBManager:
Create a table with defined columns.
CREATE TABLE NomTable (NomCol1:TypeCol1, NomCol2:TypeCol2, ..., NomColN:TypeColN(size))Rules :
-
Column names and types are separated by : with no spaces.
-
Keywords and table names are separated by a single space.
-
Example:
CREATE TABLE Clients (ID:INT, Nom:STRING(50), Age:INT)
Insert a tuple into a table.
INSERT INTO NomTable VALUES (val1, val2, ..., valn)Rules :
- Strings must be surrounded by quotes ("value").
- Example:
INSERT INTO Clients VALUES (1, "Alice", 25)
Insert data from a CSV file.
BULKINSERT INTO NomTable nomFichier.csvRetrieve data with or without conditions.
SELECT aliasRel.col1, aliasRel.col2, ... FROM NomTable aliasRel [WHERE condition]Rules :
-
Conditions follow:
col1 OP col2, whereOPis on of=,<,>,<=,>=,<>. -
Join example :
SELECT c.Nom, o.Montant FROM Clients c, Commandes o WHERE c.ID = o.ClientID
-
Create a database :
CREATE DATABASE NomDB
-
Select a database :
SET DATABASE NomDB -
List tables in the current database :
LIST TABLES
-
Drop a table :
DROP TABLE NomTable
-
List all tables :
LIST DATABASES
-
Drop a database :
DROP DATABASE NomDB
This guide explains how to run the program on Linux or macOS. Make sure you are at the project root: projet-bdda.**
The script is compatible with these systems only.
java -versionMake run.sh executable (if needed)
chmod +x run.shLe programme peut être lancé de deux manières différentes :
In this mode, the program automatically uses file-config.json in the current directory.
./run.sh./run.sh path/to/config.json