Skip to content

AmeerHossam/Database-Management-System-Using-BashScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

Database Management System

Implementing Database Management System using BashScript.

My image

What does our project do ?

  • It creates a databases , so you can create a lot of tables inside them.

  • from the concept of database management system , We can (Create,Delete,Update,Read) the content of the tables

  • also each table has a primary key , and this primary key has the power of updating and deleting from tables.

Configuration

To run the script ,you only need to change the path to your own path.

#Like here I changed to my own path
myPath=/home/amir/Database
#For windows OS Try to replace "/" with "\" and ensure that bash is installed on your system

Run the script

# 1st: you need to change the permission of the file to read and execute permissions
sudo chmod 500 script.sh
# 2nd: Run the script
./script.sh

Usage

#1st: Enter your choice
1) create
2) list
3) connect
4) drop
5) exit

Create

# HINT YOU MUST ENTER STRING ONLY OR ALPHANUMERIC VALUES
1) create
2) list
3) connect
4) drop
5) exit
#? 1
enter the database name(string only): DataBase22
DataBase created
# if you enter an integer value as an input
# It asks you to enter an input again
1) create
2) list
3) connect
4) drop
5) exit
#? 1
enter the database name(string only): 222
Invalid input
enter the database name(string only): 

List

#If you entered 2 , It lists all databases created in your own path
1) create
2) list
3) connect
4) drop
5) exit
#? 2
DataBase22
#? 

Connect

Here you connect to the database you created , for example: we're going to connect to "DataBase22" that we created

#It takes us to another window to (create,update,read,delete) tables
Please enter the database name you want to connect: DataBase22
1) Create Table	      4) Delete from Table  7) Update to table
2) List Table	      5) Insert to table
3) Drop Table	      6) Select Table
#? 

Create Table

Here we're going to create a table so it asks you the name of the table and the number of the table's column (YOU ONLY HAVE TO CHOICE BETWEEN 2 DATATYPES "INT" AND "STR")

1) Create Table	      4) Delete from Table  7) Update to table
2) List Table	      5) Insert to table
3) Drop Table	      6) Select Table
#? 1
Enter the table name: Table1
#Here for example I created a table called (Table1)
Enter table columns number: 3
#and the table has 3 columns , next I entered the datatype of each column
-------Note-------
First column is primary key
Enter the column 1 datatype[STR/INT]: int
Enter the column number 1 name : id
Enter the column 2 datatype[STR/INT]: str
Enter the column number 2 name : name
Enter the column 3 datatype[STR/INT]: int
Enter the column number 3 name : age
#? 

List Table

The script creates 2 files , one for the column's datatypes and one for the data of each column so if I listed the tables , 2 tables will be shown , In our case "Table1.datatype" and "Table1"

1) Create Table	      4) Delete from Table  7) Update to table
2) List Table	      5) Insert to table
3) Drop Table	      6) Select Table
#? 2
Table1
Table1.datatype
#? 

Insert to Table

Here we're going to insert data to the table we're created, in our case "Table1"

1) Create Table	      4) Delete from Table  7) Update to table
2) List Table	      5) Insert to table
3) Drop Table	      6) Select Table
#? 5
Enter the table you want to insert to: Table1
Enter the data of column id
You must enter a primary key
1
Enter the data of column name
Amir
Enter the data of column age
25

Select Table

In Select Table choice we have 3 choices

Please enter the database name you want to connect: DataBase22
1) Create Table	      4) Delete from Table  7) Update to table
2) List Table	      5) Insert to table
3) Drop Table	      6) Select Table
#? 6
Enter the table you want to select: Table1
1) select all records
2) select record
3) select column
  • First one is to show all content of the table:

Enter the table you want to select: Table1
1) select all records
2) select record
3) select column
#? 1
id:name:age
1:Amir:25
  • Second one is to print data with the specific primary key , for example:

1) select all records
2) select record
3) select column
#? 2
Please enter the Primary Key: 1
1:Amir:25
  • Third one is to print the data of a specific column, for example:

Enter the table you want to select: Table1
1) select all records
2) select record
3) select column
#? 3
Please enter name of the column you want to select: name
id:name:age
name
Amir
#? 

Update Table

Here we're going to update data inserted to the table

Please enter the database name you want to connect: DataBase22
1) Create Table	      4) Delete from Table  7) Update to table
2) List Table	      5) Insert to table
3) Drop Table	      6) Select Table
#? 7
Enter the table name: Table1
id:name:age
1:Amir:25
Enter the primary key to reach the row you want to update: 1
Enter the column number reach the column you want to update: 2
enter the value you want to update: Amir
1:Amir:25
Enter the new value: Omar
id:name:age
1:Omar:25
#? 

Drop from Table

Here we're going to delete the full data of a specific primary key , for example:

1) Create Table	      4) Delete from Table  7) Update to table
2) List Table	      5) Insert to table
3) Drop Table	      6) Select Table
#? 4
enter the table name you want to delete from: Table1
enter the pk of row you want to delete: 1
the row is deleted
#? 

To ensure that the data has been deleted so we are going to show the full content of the table by Select choice:

#? 6
Enter the table you want to select: Table1
1) select all records
2) select record
3) select column
#? 1
id:name:age

Drop table

In this case we are going to delete the table from our database , for example:

1) Create Table	      4) Delete from Table  7) Update to table
2) List Table	      5) Insert to table
3) Drop Table	      6) Select Table
#? 3
Please enter the DB table you want to remove: Table1
rm: remove regular file '/home/amir/Database/DataBase22/Table1'? yes
rm: remove regular file '/home/amir/Database/DataBase22/Table1.datatype'? yes
#? 2
#? 

"See when we entered "2" which for listing all tables in our database , It prints nothing "

Let's get back to our first menu ,,,

1) create
2) list
3) connect
4) drop
5) exit

Lets try to drop our database,,,

1) create
2) list
3) connect
4) drop
5) exit
#? 4
enter the database you want to delete: DataBase22
are you sure that you want to delete DataBase22 [Y/N]?: y
#? 2
#? 

"The same concept of deleting table , we dropped it and checked it by entering "2" for list all databases created in my system.

Team

  • Amir HossamEldien

  • Abdulrahman Mostafa

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages