A lightweight database management system implementation based on CMU-15445 BusTub framework, adapted for educational purposes and MiniSQL experiment requirements.
MiniSQL is a simplified database system that implements core database components including buffer pool management, indexing, record management, and query execution.
- Buffer Pool Management: LRU replacement policy and buffer pool manager
- Index Management: B+ Tree indexing with support for various data types
- Record Management: Row-based storage with schema management
- Query Execution: SQL parser and executor with support for basic operations
- Concurrency Control: Transaction management and locking mechanisms
- Storage Management: Disk-based storage with page management
The system is organized into several key modules:
- Buffer Manager: Manages memory pages and implements LRU replacement
- Storage Manager: Handles disk I/O and file management
- Index Manager: Implements B+ Tree indexes for efficient data access
- Record Manager: Manages table records and schemas
- Catalog Manager: Maintains database metadata and schema information
- Query Executor: Executes SQL queries with various execution plans
- Data Definition: CREATE TABLE, DROP TABLE, CREATE INDEX, DROP INDEX
- Data Manipulation: INSERT, DELETE, UPDATE, SELECT
- Query Types: Sequential scan, index scan, nested loop joins
- Compiler:
- Apple clang 11.0+ (macOS)
- GCC/G++ 8.0+ (Linux)
- Build System: CMake 3.20+
- Debugger: GDB 7.0+ (optional)
- Parser Tools: Flex & Bison (for SQL grammar modifications)
- ✅ macOS (native)
- ✅ Linux (native)
- ✅ Windows (via WSL - Ubuntu 20+ recommended)
# Clone the repository
git clone <repository-url>
cd minisql-master
# Create build directory
mkdir build
cd build
# Configure and build
cmake ..
make -j$(nproc)Debug Build (default):
cmake ..
make -jRelease Build:
cmake -DCMAKE_BUILD_TYPE=Release ..
make -jClean Build:
# Use the provided clean script
./clean.sh
# Or manually
rm -rf build
mkdir build
cd build
cmake ..
make -jFor Windows users, install WSL with Ubuntu 20+ and follow the Linux build instructions. For IDE integration, see CLion with WSL.
cd build/test
./minisql_test# Build specific test
make lru_replacer_test
make buffer_pool_manager_test
make b_plus_tree_test
# Run from build directory
./test/lru_replacer_test
./test/buffer_pool_manager_test- Buffer Management:
lru_replacer_test,buffer_pool_manager_test - Index Management:
b_plus_tree_test,b_plus_tree_index_test,index_iterator_test - Storage:
disk_manager_test,table_heap_test - Catalog:
catalog_test - Concurrency:
lock_manager_test - Recovery:
recovery_manager_test - Execution:
executor_test
minisql-master/
├── src/ # Source code
│ ├── buffer/ # Buffer pool management
│ ├── catalog/ # Database catalog
│ ├── concurrency/ # Transaction and locking
│ ├── executor/ # Query execution
│ ├── index/ # B+ Tree indexing
│ ├── page/ # Page management
│ ├── parser/ # SQL parsing
│ ├── planner/ # Query planning
│ ├── record/ # Record management
│ ├── storage/ # Storage management
│ └── main.cpp # Entry point
├── test/ # Test suites
├── thirdparty/ # Third-party dependencies
│ ├── googletest/ # Google Test framework
│ └── glog/ # Google Logging
├── CMakeLists.txt # Build configuration
├── LICENSE # MIT License
└── README.md # This file
This implementation includes several enhancements over the original BusTub framework:
- Enhanced Disk Manager: Extended with bitmap pages and disk file metadata pages for persistent page allocation tracking
- Serialization Support: Memory object serialization/deserialization for data persistence in Record Manager, Index Manager, and Catalog Manager
- Refactored Record Manager: Restructured data structures (
Row,Field,Schema,Column) and implementations - Persistent Catalog Manager: Redesigned to support persistence and provide interfaces for the Executor layer
- Extended Parser: Enhanced to output syntax trees for Executor layer consumption
-- Create a table
CREATE TABLE students (
id INT PRIMARY KEY,
name VARCHAR(50),
age INT
);
-- Create an index
CREATE INDEX idx_name ON students(name);
-- Insert data
INSERT INTO students VALUES (1, 'Alice', 20);
INSERT INTO students VALUES (2, 'Bob', 22);
-- Query data
SELECT * FROM students WHERE age > 21;
-- Update data
UPDATE students SET age = 23 WHERE id = 1;
-- Delete data
DELETE FROM students WHERE id = 2;- The project uses C++17 standard
- Debug builds include comprehensive logging and error checking
- Memory leak detection is available on supported platforms
- Code formatting follows clang-format standards
This project is licensed under the MIT License - see the LICENSE file for details.
- Based on CMU-15445 BusTub framework
- Uses Google Test for unit testing
- Uses Google Logging for debug output
This is an educational project. Please ensure any modifications maintain the academic integrity of the codebase and follow the existing code style and architecture patterns.