CustomDB is an educational project designed to explore fundamental data structures and algorithms by creating a simple database management system. This project demonstrates how structures like linked lists, hashmaps, and red-black trees can be used to efficiently manage and manipulate data.
CustomDB simulates key database functionalities, providing a hands-on experience in designing and implementing data structures. Developed in C, the project avoids external libraries to focus on foundational programming skills.
- Table Management: Dynamically create and delete tables.
- Record Operations: Add, delete, update, and query records within tables.
- Indexing: Use red-black trees to create and maintain indexes for efficient data retrieval.
- Sorted Queries: Retrieve records in sorted order based on primary key.
- Purpose: Implements doubly linked lists for managing table records.
- Benefits: Supports dynamic memory allocation and efficient record insertion and deletion.
- Purpose: Maps table names to their respective data structures.
- Benefits: Enables constant-time lookup for table management, ensuring scalability.
- Purpose: Maintains indexes on primary keys for quick searching and sorting.
- Benefits: Guarantees balanced operations with (O(log n)) complexity for insertions, deletions, and lookups.
CustomDB offers a command-driven interface for the following operations:
- CREATE/DELETE TABLE
<table_name>
: Create or delete tables dynamically. - CREATE INDEX
<table_name>
: Build an index on the primary key using a red-black tree. - ADD
<table_name>
<column_name>
<value>
: Add a new record to a table. - DELETE
<table_name>
<column_name>
<value>
: Remove records where the column matches the value. - UPDATE
<table_name>
<column_name>
<value>
<new_value>
: Update values in matching records. - SELECT
<table_name>
<column_name>
<value>
[SORTED]: Query and optionally sort records by primary key. - PRINT TABLE
<table name>
: Print the table
CustomDB supports a predefined schema with the following columns:
-
student_id: An integer representing the unique ID of a student (primary key).
-
course_name_general: A string (up to 32 characters) for the name of a general course.
-
general_course_instructor: A string (up to 32 characters) for the instructor of a general course.
-
general_course_score: An integer score (0 to 20) for the general course.
-
course_name_core: A string (up to 32 characters) for the name of a core course.
-
core_course_instructor: A string (up to 32 characters) for the instructor of a core course.
-
core_course_score: An integer score (0 to 20) for the core course.
CustomDB is designed to:
- Learn Data Structures: Demonstrate practical applications of linked lists, hashmaps, and red-black trees.
- Enhance Algorithm Design Skills: Explore efficient sorting and data manipulation algorithms.
- Highlight Performance: Show the importance of (O(1)) and (O(log n)) complexities for operations.
-
Compile the Project: Use the provided Makefile:
make all
-
Run the Program:
./main
- Supports only a predefined table schema.
- Intended for educational purposes, lacking production-level optimizations.
CustomDB bridges the gap between theoretical concepts and practical applications by integrating core data structures into a functioning database system. It provides a valuable learning experience for students and enthusiasts seeking to deepen their understanding of data structures in real-world use cases.