A Java-based educational project demonstrating database transaction execution with support for concurrent transaction processing.
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
The current implementation executes transactions serially (one after another). This ensures correctness but does not take advantage of potential parallelism.
This project is designed as a foundation for implementing:
- Concurrent Transaction Execution: Modify
executeTransactions()to run transactions in parallel - Concurrency Control: Implement locking mechanisms (e.g., two-phase locking)
- Isolation Levels: Add support for different transaction isolation levels
- Conflict Detection: Identify and handle read-write and write-write conflicts
- Deadlock Prevention: Implement strategies to prevent or detect deadlocks
- Java Development Kit (JDK) 8 or higher
- No external dependencies required
.
├── 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
- Purpose: Main database engine that manages 100 rows and executes transactions
- Key Methods:
executeTransactions(List<Transaction>): Processes a batch of transactionsmain(): Example usage demonstrating two transactions
- Purpose: Represents a database transaction containing a sequence of operations
- Key Methods:
addOperation(Operation): Adds an operation to the transactiongetOperations(): Returns the list of operations
- Purpose: Represents a single READ or WRITE operation
- Attributes:
type: 0 for READ, 1 for WRITErowNumber: Target row index (0-99)value: For READ (return value), for WRITE (value to write)
- Purpose: Simple data structure representing a database row
- Attributes:
value: Integer value stored in the row
javac *.javajava Databaseexecuting READ row 3
executing WRITE row 4 value 5
executing WRITE row 3 value 99
executing READ row 4