Skip to content

About

Simplified database implementation

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Database Transaction Implementation

A Java-based educational project demonstrating database transaction execution with support for concurrent transaction processing.

Project Overview

This project implements a simplified in-memory database system that supports:

  • 100 rows of integer data storage
  • READ and WRITE operations on individual rows
  • Transaction-based execution with multiple operations per transaction
  • A framework designed to be extended from serial to concurrent execution

Current Implementation

The current implementation executes transactions serially (one after another). This ensures correctness but does not take advantage of potential parallelism.

Extension Opportunities

This project is designed as a foundation for implementing:

  1. Concurrent Transaction Execution: Modify executeTransactions() to run transactions in parallel
  2. Concurrency Control: Implement locking mechanisms (e.g., two-phase locking)
  3. Isolation Levels: Add support for different transaction isolation levels
  4. Conflict Detection: Identify and handle read-write and write-write conflicts
  5. Deadlock Prevention: Implement strategies to prevent or detect deadlocks

Requirements

  • Java Development Kit (JDK) 8 or higher
  • No external dependencies required

Project Structure

.
├── Database.java      # Main database class with transaction execution logic
├── Transaction.java   # Transaction container holding multiple operations
├── Operation.java     # Individual READ/WRITE operation definition
├── Row.java          # Data row representation
└── README.md         # This file

Class Descriptions

Database.java

  • Purpose: Main database engine that manages 100 rows and executes transactions
  • Key Methods:
    • executeTransactions(List<Transaction>): Processes a batch of transactions
    • main(): Example usage demonstrating two transactions

Transaction.java

  • Purpose: Represents a database transaction containing a sequence of operations
  • Key Methods:
    • addOperation(Operation): Adds an operation to the transaction
    • getOperations(): Returns the list of operations

Operation.java

  • Purpose: Represents a single READ or WRITE operation
  • Attributes:
    • type: 0 for READ, 1 for WRITE
    • rowNumber: Target row index (0-99)
    • value: For READ (return value), for WRITE (value to write)

Row.java

  • Purpose: Simple data structure representing a database row
  • Attributes:
    • value: Integer value stored in the row

Usage

Compilation

javac *.java

Running the Example

java Database

Example Output

executing READ row 3
executing WRITE row 4 value 5
executing WRITE row 3 value 99
executing READ row 4

About

Simplified database implementation

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages