Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/melinteflxrin/database-management-system-oop
A lightweight implementation of a database management system, similar to SQLite.
https://github.com/melinteflxrin/database-management-system-oop
database database-management dbms sql sqlite sqlite-database
Last synced: 22 days ago
JSON representation
A lightweight implementation of a database management system, similar to SQLite.
- Host: GitHub
- URL: https://github.com/melinteflxrin/database-management-system-oop
- Owner: melinteflxrin
- Created: 2025-01-02T18:25:40.000Z (about 2 months ago)
- Default Branch: master
- Last Pushed: 2025-01-28T15:24:44.000Z (23 days ago)
- Last Synced: 2025-01-28T16:29:27.475Z (23 days ago)
- Topics: database, database-management, dbms, sql, sqlite, sqlite-database
- Language: C++
- Homepage:
- Size: 188 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DBMS - My SQLite Engine
## Table of contents
1. [Description](#description)
2. [Commands](#commands)
3. [File Management](#file-management)
4. [Demo Video](#demo-video)
## Description
A lightweight implementation of a database management system, similar to SQLite.This project was part of an optional OOP class assignment designed to gain practical experience and see how different classes are combined together to develop a “real” software product.
The application handles basic SQL commands, enables faster lookups using indexes, manages files for data import, stores table structures to maintain the database state, and more.
## Commands
There are 20 available commands, including a help menu and a syntax menu that provide descriptions and syntax details for all commands.
They allow the user to create and manage tables, insert and update data, create indexes for faster lookups, retrieve data with select commands, and more.
```
Basic Operations:
1. CREATE TABLE
2. DESCRIBE TABLE
3. DROP TABLEData Manipulation:
4. INSERT
5. DELETE WHERE
6. UPDATE TABLE
7. ALTER TABLE ADD COLUMN
8. ALTER TABLE DROP COLUMN
9. IMPORTIndex Operations:
10. CREATE INDEX
11. DROP INDEXSelect Commands:
12. SELECT ALL
13. SELECT ALL WHERE
14. SELECT COLUMNS
15. SELECT WHEREDatabase Information:
16. SHOW TABLES
17. SHOW INDEX FROM TABLE
18. SHOW INDEX FROM ALLUtility Commands:
19. HELP MENU (help)
20. SYNTAX MENU (help 2)
21. clear
22. exit
```
- ### Creating a table:
Each column has the following attributes: column_name, type (INT, TEXT or FLOAT), size, default_value, and an optional UNIQUE constraint that ensures all values in the column are different.
```
CREATE TABLE Products ((ID, INT, 5, 0, UNIQUE),(Name, TEXT, 20, unknown), (Price, FLOAT, 10, 0.0))
```
Displaying the table structure:
```
DESCRIBE Products
```

Dropping a table (also removes all the indexes associated with that table):
```
DROP TABLE Products
```
- ### Inserting data:
Values from insert commands are separated by , and they have the same number and order as the table definition.
When inserting new data, index information is also updated on all columns from the table that have an index created on them.
```
INSERT INTO Products VALUES (123, Laptop, 3799.99)
INSERT INTO Products VALUES (124, TV, 1599.99)
INSERT INTO Products VALUES (125, Laptop, 2850.99)
```
- ### Indexes:
#### Creating an index on a column:
```
CREATE INDEX nameIndex ON Products (Name)
```
#### Index information:
Shows all indexes from a table, and all indexes from all tables, respectively.
```
SHOW INDEX FROM Products
SHOW INDEX FROM ALL
```

#### Dropping an index:
```
DROP INDEX nameIndex
```- ### Select commands:
#### Searching *without* an index:
```
SELECT ALL FROM Products
SELECT ID,Name FROM Products
SELECT ALL FROM Products WHERE ID=123
```

#### Searching *with* an index (from column 'Name'):
```
SELECT ALL FROM Products WHERE Name=Laptop
```
- ### Update & Alter:
Updating data on a column that has an index created on it will also update the index on that column.
```
UPDATE Products SET Name=Phone WHERE ID=125
```

Adding a new column to a table will initialize the existing rows with the new column's default value.
```
ALTER TABLE Products ADD (Weight,FLOAT,5,0)
```

Dropping a column:
```
ALTER TABLE Products DROP COLUMN Weight
```
- ### Deleting rows:
Deleting rows from a table will also update the indexes from all columns which have an index created on them.
It also uses the WHERE condition to search for data quicker using the index (if the column has an index).
```
DELETE FROM Products WHERE Name=TV
```
## File Management:
- ### Start commands:
The application can receive one or more input text files through the arguments of the main function.
For example, if the application is called *DBMS PROJECT.exe*, it can be launched with a command like the following:
```
"DBMS PROJECT.exe" commands1.txt commands2.txt
```
If the text files containing the start commands are not in the same directory as the application, the full path to each file is needed as an argument.
Can also be started without recieving any arguments.
- ### Table configuration files:
All table details such as table structure, data, index information, are stored in configuration binary files. Each table in the database has its own associated binary file, with the same name as the table.
The configuration files are used by the application at startup to load the database and all table information.
Upon exiting the application, all modifications made to the tables during the session are saved, and the binary files are updated.- ### Select commands:
The execution of *SELECT* commands automatically generates text files containing the results of the commands.
The filenames are generated automatically, following this format: *SELECT_1.txt, SELECT_2.txt, etc.*- ### Importing data from CSV files:
The application allows the upload of data from CSV files, similar to *INSERT* commands.
The delimiter symbol (e.g.```,``` , ```#```, or others) is chosen by the user.Importing CSV files can be done like this:
```
IMPORT INTO Products file_name.csv
```
- ### Settings file:
The program starts by reading configuration details from a ```settings.txt``` file located in the same directory as the application.The file contains the following information (must be in this order to be read correctly):
- The address of the folder containing the tables' configuration files
- The address for the output of *SELECT* commands
- The address of the folder containing *CSV* files that can be imported
- The delimiter for the *CSV* files## Demo Video
Here is a quick video showcasing how commands work and how the program manages files.
- https://www.youtube.com/watch?v=-Q0qjhDrciE