This repository contains a simple, file-backed database system implemented in Java. The system is designed to demonstrate fundamental database concepts, including schema and tuple management, basic table operations (insert, delete, lookup), and query evaluation. A core feature of this project is the implementation of a natural join operation on two tables, as well as SELECT queries with conditional filtering.
For sample I/O traces and additional information, visit the project page: https://www.rsiddiq.com/database-systems.html
The project is organized using a standard Maven directory layout:
.
├── .mvn/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── natjoin/
│ │ │ ├── resource/
│ │ │ └── (core classes)
│ │ └── resources/
│ └── test/
│ └── java/
│ └── natjoin/
│ └── (test classes)
├── .gitignore
├── pom.xml
└── mvnw
└── mvnw.cmd
src/main/java/natjoin/: Contains the core classes for the database system, such asTable.java,Tuple.java, andSchema.java.src/main/java/natjoin/resource/: Houses the classes related to query handling and conditions, includingSelectQuery.javaandCondition.java.src/test/java/natjoin/: Contains JUnit tests for the various components of the system, such asJoinTest.javaandTableTest.java.pom.xml: The Maven project configuration file. It specifies project dependencies, such as JUnit 5 for testing, and defines build plugins.mvnwandmvnw.cmd: These are the Maven wrapper scripts for Unix/Linux and Windows, respectively. They ensure a consistent Maven version across different development environments without requiring a manual Maven installation.
The project provides an in-memory implementation of a relational database system with the following key features:
- Tables and Schemas: Tables are defined by a
Schema, which specifies the column names and their data types (intandvarchar). - Tuples: Tuples (rows) are the fundamental data units, containing values that conform to a table's schema.
- CRUD Operations: The
ITableinterface defines methods for basic data manipulation:insert,delete, andlookup. - Select Queries: The
SelectQueryclass can filter tuples from a table based on various conditions (EqCondition,AndCondition,OrCondition). - Natural Join: The
SelectQueryclass also contains a staticnaturalJoinmethod that combines two tables based on their common column names.
- Java Development Kit (JDK): Version 17 or higher.
- Maven: The project includes the Maven wrapper (
mvnw), so a separate installation is not required.
To build the project and run the main application:
- Navigate to the project's root directory.
- Use the Maven wrapper to compile the project:
./mvnw compile - To run the main application, execute the following command:
This will execute the example in
./mvnw exec:java -Dexec.mainClass="natjoin.MainApplication"MainApplication.java, which demonstrates table creation, data insertion, deletion, and a natural join.
To run the project's unit tests, use the Maven wrapper with the test command:
./mvnw test
This will automatically find and execute all test classes in the src/test/java directory, as configured in the pom.xml.