Simple Twitter
This is a simple SQL-like Database Management System (DBMS) implemented in C++. It provides basic functionalities for managing a database, including INSERT, SELECT, DELETE, and UPDATE operations. The system uses text files to store and manipulate data.
Overview
The DBMS supports the following operations:
- INSERT: Insert data into a table.
- SELECT: Retrieve data from a table.
- DELETE: Remove data from a table.
- UPDATE: Modify data in a table.
The system reads and writes data to text files, with each table represented by a separate file. The schema of the database is defined in a file called schema.txt
, which lists the tables and their columns.
Functions
The DBMS provides the following functions:
vector INSERT(string str): Inserts data into a table. vector SELECT(string str): Retrieves data from a table. vector DELETE(string str): Deletes data from a table. vector UPDATE(string str): Updates data in a table. vector database(string stri): Main function that parses and executes SQL-like commands.
Error Handling
The DBMS includes error handling for various scenarios, such as invalid input, mismatched data types, and attempts to update non-existing records. Error messages are displayed in the console to assist users in identifying and correcting issues.
Schema
The database schema is defined in the schema.txt file, which lists the tables and their columns. Each line represents a table, with columns separated by spaces. The schema file is essential for validating input and ensuring data consistency.
Sample Input
To interact with the DBMS, you can input SQL-like commands prefixed with ~$. Below is a sample INSERT command:
input
$ INSERT INTO users VALUES (16,zahra,zahrakhtb1,123,Tue/Aug/11/23:45:26/2020,0);