A comprehensive, file-based Database Management System (DBMS) prototype built in Java, implementing core database functionalities including SQL query processing, transaction management, indexing, user authentication, and concurrency control.
Author: Bryan Vela
Version: 1.0.0
- Database Management: Create, use, and list databases
- Table Operations: Create tables with column definitions and data types
- SQL Query Support: SELECT, INSERT, UPDATE, DELETE operations
- Data Types: INTEGER, INT, VARCHAR(n), STRING, TEXT, FLOAT, DATE, BOOLEAN
- User Authentication: Secure login with SHA-256 password hashing
- Session Management: Session-based access control
- Password Recovery: Security question-based password reset
- Audit Logging: Comprehensive security event tracking
- Access Control: User-based database access permissions
- B-Tree Indexing: Order 5 B-Tree implementation for efficient data retrieval
- Transaction Management: Full ACID-compliant transactions
- Concurrency Control: Lock management and deadlock detection
- Query Parser & Validator: Robust SQL parsing and semantic validation
- File-Based Storage: Custom storage system with organized file structure
- Interactive Console: Full-featured command-line interface
- Command History: Track and retrieve previous commands
- Contextual Prompts: Dynamic prompts showing current database context
- Comprehensive Help: Built-in help system and command documentation
src/com/dbms/
├── Main.java # Application entry point
├── controller/ # Business logic layer
│ └── DBMSController.java # Main database operations controller
├── model/ # Data models
│ ├── Database.java # Database entity
│ ├── Table.java # Table entity
│ ├── Column.java # Column definition
│ └── User.java # User entity
├── query/ # SQL processing
│ ├── QueryParser.java # SQL statement parsing
│ ├── QueryExecutor.java # Query execution engine
│ ├── QueryValidator.java # Semantic validation
│ └── [Query Types].java # Specific query implementations
├── storage/ # Persistence layer
│ ├── StorageManager.java # File-based storage system
│ ├── FileHandler.java # File I/O operations
│ └── IStorageProvider.java # Storage abstraction
├── index/ # Indexing system
│ ├── BTree.java # B-Tree implementation
│ ├── BTreeNode.java # B-Tree node structure
│ └── IndexManager.java # Index management
├── transaction/ # Transaction management
│ ├── TransactionManager.java # ACID transaction control
│ ├── Transaction.java # Transaction entity
│ └── TransactionOperation.java # Operation tracking
├── concurrency/ # Concurrency control
│ └── LockManager.java # Lock and deadlock management
├── security/ # Security layer
│ ├── Authentication.java # User authentication
│ ├── AuditLogger.java # Security event logging
│ ├── SessionManager.java # Session management
│ └── PasswordRecovery.java # Password reset functionality
├── ui/ # User interface
│ └── ConsoleUI.java # Interactive command-line interface
└── util/ # Utilities
└── Constants.java # Application constants
storage/
├── users/ # User account data
├── logs/
│ ├── audit/ # Security audit logs
│ └── transactions/ # Transaction logs
├── database/ # Database files
├── indexes/ # B-Tree index files
├── security/ # Security-related files
├── config/ # Configuration files
└── general/ # General purpose files
- Java JDK 8 or higher
- Terminal/Command Prompt access
-
Clone the repository
git clone [repository-url] cd dbms-prototype -
Compile the project
javac -cp . -d bin src/com/dbms/**/*.java
-
Run the application
java -cp bin com.dbms.Main
-
Register a new user
- Choose option 2 from the login menu
- Provide username, password, email, and security question
-
Login and start using the DBMS
- Use your credentials to login
- Start creating databases and tables
CREATE DATABASE mydb -- Create a new database
USE mydb -- Select a database to use
SHOW DATABASES -- List all databases-- Create a table
CREATE TABLE users (
id INTEGER PRIMARY KEY,
name VARCHAR(50),
email STRING,
age INTEGER
);
SHOW TABLES -- List tables in current database
DESCRIBE users -- Show table structure-- Insert data
INSERT INTO users (id, name, email, age)
VALUES (1, 'John Doe', 'john@email.com', 25);
-- Query data
SELECT * FROM users;
SELECT name, email FROM users WHERE age > 20;
-- Update data
UPDATE users SET age = 26 WHERE id = 1;
-- Delete data
DELETE FROM users WHERE id = 1;HELP -- Show available commands
STATUS -- Show system status
LOGOUT -- Logout current user
EXIT -- Exit applicationBEGIN TRANSACTION; -- Start a transaction
-- Execute multiple operations
COMMIT; -- Commit changes
-- or
ROLLBACK; -- Rollback changesINTEGER/INT: Whole numbersVARCHAR(n): Variable-length strings with max lengthSTRING/TEXT: Variable-length stringsFLOAT: Decimal numbersDATE: Date valuesBOOLEAN: True/false values
- Order: 5 (maximum 4 keys per node)
- Operations: Insert, search, delete, range queries
- Performance: O(log n) for basic operations
- Atomicity: All operations succeed or none do
- Consistency: Database maintains valid state
- Isolation: Concurrent transactions don't interfere
- Durability: Committed changes persist
- Password Hashing: SHA-256 with salt
- Session Management: Secure session tokens
- Audit Logging: All security events tracked
- Access Control: User-based permissions
dbms-prototype/
├── README.md # Project documentation
├── src/ # Source code
├── bin/ # Compiled classes
├── docs/ # Architecture diagrams
│ ├── 1_MainArchitecture.png
│ ├── 2_UML_Diagram.png
│ ├── 3_FileStorageStructure.png
│ ├── 4_AuthenticationFlow.png
│ ├── 5_PasswordRecoveryFlow.png
│ ├── 6_QueryExecutionFlow.png
│ ├── 7_TransactionFlow.png
│ ├── 8_ConcurrencyControlFlow.png
│ └── 9_IndexUpdateFlow.png
├── storage/ # Runtime data files
└── lib/ # External dependencies (if any)
The system can be tested through the interactive console interface:
- User Management: Registration, login, password recovery
- Database Operations: Create/use databases, create tables
- Query Operations: Insert, select, update, delete data
- Transaction Testing: Begin, commit, rollback operations
- Security Testing: Authentication, session management
# Test database creation and table operations
CREATE DATABASE testdb;
USE testdb;
CREATE TABLE products (id INTEGER, name STRING, price FLOAT);
# Test data operations
INSERT INTO products (id, name, price) VALUES (1, 'Laptop', 999.99);
SELECT * FROM products;
UPDATE products SET price = 899.99 WHERE id = 1;
DELETE FROM products WHERE id = 1;# Compile all Java files
javac -cp . -d bin src/com/dbms/**/*.java
# Run the application
java -cp bin com.dbms.Main- Modular Design: Clear separation of concerns
- Interface-based: Abstractions for storage and other components
- Exception Handling: Comprehensive error management
- Documentation: Javadoc comments throughout
Contact: Bryan Vela