Database Labreport
Database Labreport
3.Drop Database:
DROP DATABASE databasename;
Example: DROP DATABASE Sanjida;
7.2:If we want to add extra column to an existing table we can use alter table
to add column;
ALTER TABLE table_name
ADD column_name datatype;
Example:
ALTER TABLE student
ADD Department varchar(10);
7.3: If we want to drop a column from an existing table we can use alter table
to drop column;
ALTER TABLE table_name
DROP COLUMN column_name;
Example:
ALTER TABLE student
DROP COLUMN Department;
Console:
LAB 3(24/01/2024)
We have learned following topic in the lab:
1.Firstly we repeated the process of creating database and table as we
learned in the previous lecture.
2.How to add UNIQUE key to an existing table.
3.Insert Information Into the table.
4.Lastly we performed various type of operations.
5.Various operation:
5.1:Print all information.
Queries: SELECT * FROM customer
(N.B:’%’ uses of this sign indicates that anything can be placed before
‘gmail.com’ but string should be end with ‘gmail.com’. This called ‘LIKE’
operator. The percent sign % represents zero, one, or multiple characters)
Console(png):
LAB 4(31/01/2024)
We have learned following topic in the lab:
1.Perform different queries operation on an existing table
Table(png):
xvi)Calculate % of comparison:
Queries: SELECT
Console(png):
LAB 5(05/02/2024)
Table(png):
Queries that we performed in today’s lab:
1.Print Full Name of every customers.
SELECT first_name || ‘ ‘ || last_name FROM Customers
Lab 6(07/02/2024)
customer table:
orders table:
Left Join:
Query: SELECT *
FROM customer
LEFT JOIN orders
ON customer.c_id = order.c_id;
Right Join:
Query: SELECT *
FROM customer
RIGHT JOIN orders
ON customer.c_id = order.c_id;
Full Join
Query: SELECT *
FROM customer
FULL OUTER JOIN orders
ON customer.c_id = order.c_id
WHERE condition;
Completed Task:
Console:
Some key points that we should keep in mind to create relational database:
Draw a demo database schema at first
Determine the Primary key and Foreign key which is a must
Start creating the table from Left-to-Right
Sometimes queries might not work as expected, so we should try in different
ways
Lab 9()
In todays lab, we learned how to draw an ER diagram using online based tool draw.io:
Lab work: