Skip to content

The project is a basic in-memory database system that demonstrates fundamental concepts like schema, tuples, table operations, and a natural join.

Notifications You must be signed in to change notification settings

r-siddiq/NatJoin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NatJoin: A Simple Database System

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


Project Structure

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 as Table.java, Tuple.java, and Schema.java.
  • src/main/java/natjoin/resource/: Houses the classes related to query handling and conditions, including SelectQuery.java and Condition.java.
  • src/test/java/natjoin/: Contains JUnit tests for the various components of the system, such as JoinTest.java and TableTest.java.
  • pom.xml: The Maven project configuration file. It specifies project dependencies, such as JUnit 5 for testing, and defines build plugins.
  • mvnw and mvnw.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.

Functionality

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 (int and varchar).
  • Tuples: Tuples (rows) are the fundamental data units, containing values that conform to a table's schema.
  • CRUD Operations: The ITable interface defines methods for basic data manipulation: insert, delete, and lookup.
  • Select Queries: The SelectQuery class can filter tuples from a table based on various conditions (EqCondition, AndCondition, OrCondition).
  • Natural Join: The SelectQuery class also contains a static naturalJoin method that combines two tables based on their common column names.

Prerequisites

  • Java Development Kit (JDK): Version 17 or higher.
  • Maven: The project includes the Maven wrapper (mvnw), so a separate installation is not required.

Building and Running

To build the project and run the main application:

  1. Navigate to the project's root directory.
  2. Use the Maven wrapper to compile the project:
    ./mvnw compile
    
  3. To run the main application, execute the following command:
    ./mvnw exec:java -Dexec.mainClass="natjoin.MainApplication"
    
    This will execute the example in MainApplication.java, which demonstrates table creation, data insertion, deletion, and a natural join.

Running Tests

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.

About

The project is a basic in-memory database system that demonstrates fundamental concepts like schema, tuples, table operations, and a natural join.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages