A Database written entirely in C.
- Giada Amaducci
- Anna Fabris
- Riccardo Lucchi
The project simulates the management of a Database using text files (.txt) for data storage. To test it's enought to compile everything with c99 and run main.c
.
The project is structured in 3 folders:
data
, which contains the queries that will be executed when the program is run;results
, which contains the output files generated by the program;src
, which contains the program;
Each table of the Database will be stored in a different text file.
- The management of each table of the Database will be done using commands in a language provided in the project specifications, which echoes the SQL syntax.
Here all the possible commands:
CREATE TABLE table_name (column1_name,…)
INSERT INTO table_name (column1_name,…) VALUES (value1,…)
CREATE TABLE table_name (column1_name,…)
SELECT * FROM table_name
SELECT * FROM table_name ORDER BY column1_name ASC
, instead ofASC
,DESC
can be usedSELECT * FROM table_name WHERE condition
, where condition can be==
,>
,>=
,<
or<=
SELECT column1_name,… FROM table_name
SELECT column1_name,… FROM table_name WHERE condition
, where condition can be==
,>
,>=
,<
or<=
SELECT column1_name,… FROM table_name ORDER BY column2_name ASC
, instead ofASC
,DESC
can be usedSELECT column1_name FROM table_name GROUP BY column1_name
To represent the Database in the text files (output) the output is provided in the following way.
TABLE table_name COLUMNS column1_name,..;
ROW value1,...;
ROW value2,...;
In order to better manage the database tables, we chose to rely on a data structure that consists in a dynamic array of pointers, each of which identifies an array of strings corresponding to the values of each column in the row.
Below an example of a possible table and how it is stored by the program.
Surname | Name | Phone |
---|---|---|
Bianchi | Mario | 123456 |
Rossi | Paolo | 43215 |
... | ... | ... |