Lab Manual For DBMS
Lab Manual For DBMS
Example:
Required Knowledge:
ERD
Tables: Faculty, Student, Course, Subjects, Exams, Department, Hostel (Draw Tables and identification of
primary key : Students)
Student`s Task:
Draw ERD and design Tables for
1. Bank Management System 9. Vehicle Parking Management System
2. Galgotias University Management System 10. Restaurant Management System
3. School Management System 11. Pharmacy Management System
4. Hostel Management System 12. Railway Management System
5. Hotel Management System 13. ATM Management System
6. Society Management System 14. Event Management System
7. Library Management System 15. Car Showroom Management System
8. Hospital Management System 16. Pharmacy Management System
Lab :2
E2UC302B : Data Base management System
B.Tech CSE (AIML) _ 2023-24 _Sem III
Date:
Objective:
1. Create Table: The CREATE TABLE statement defines a new table named Books with columns for BookID, Title,
Author, PublishedDate, and ISBN. The BookID column is defined as the primary key.
2. Alter Table to Add Column: The ALTER TABLE statement with ADD adds a new column Genre to the Books
table.
3. Modify Column: The ALTER TABLE statement with MODIFY changes the ISBN column to have a length of 20
characters instead of 13.
4. Drop Column: The ALTER TABLE statement with DROP COLUMN removes the PublishedDate column from
the Books table.
5. Drop Table: The DROP TABLE statement completely removes the Books table from the database.
Lab :3
E2UC302B : Data Base management System
B.Tech CSE (AIML) _ 2023-24 _Sem III
Date:
Objective:
b) Update the Books table to change the Price of the book with Book ID 1 to 12.99.
c) Delete the book with Book ID 2 from the Books table.
b. Update the Books table to change the Price of the book with BookID = 1 to 12.99
UPDATE Books
SET Price = 12.99
WHERE BookID = 1;
c. Delete the book with BookID = 2 from the Books table
DELETE FROM Books
WHERE BookID = 2;
Explanation:
1. Insert Data:
o The INSERT INTO statement is used to add two rows of data into the Books table.
o Each row corresponds to a book with details such as BookID, Title, Author,
PublishedDate, ISBN, and Price.
2. Update Data:
o The UPDATE statement modifies the Price of the book where BookID equals 1.
o The price is updated from 10.99 to 12.99.
3. Delete Data:
o The DELETE statement removes the book with BookID = 2 from the Books table.
Lab :3
E2UC302B : Data Base management System
B.Tech CSE (AIML) _ 2023-24 _Sem III
Date:
Objective:
To implement the tasks assume the structure of the Products and Sales tables as follows:
Table Structure Assumptions:
Products Table:
o ProductID (Primary Key)
o ProductName (VARCHAR)
o Price (DECIMAL)
Sales Table:
o SaleID (Primary Key)
o ProductID (Foreign Key)
o SaleDate (DATE)
o Quantity (INT)
o Price (DECIMAL) — This can be the price at the time of sale.
Table Assumed:
1. Products Table
CREATE TABLE Products
(
ProductID INT PRIMARY KEY,
ProductName VARCHAR(100),
Price DECIMAL(10, 2)
);
2. Sales Table
CREATE TABLE Sales
(
SaleID INT PRIMARY KEY,
ProductID INT,
SaleDate DATE,
Quantity INT,
SalePrice DECIMAL(10, 2),
FOREIGN KEY (ProductID) REFERENCES Products(ProductID)
);
(Note: The above query assumes you want to find unique product names and sale prices as distinct items, but if you
meant something else, the query might need adjustments.)
5. Find the total revenue generated from sales
SELECT SUM(Quantity * SalePrice) AS TotalRevenue
FROM Sales;
Explanation:
1. Products with Price > 100:
o The SELECT query filters products based on the Price column, returning only those with a price
greater than 100.
2. Sales in 2023:
o The YEAR() function extracts the year part from the SaleDate and filters for records in 2023.
3. Products Containing 'Pro':
o The LIKE operator is used to search for the substring 'Pro' within the ProductName column.
4. Combine Product Names and Sale Items:
o The UNION operator combines the results from the Products and Sales tables and returns
unique values from both sets.
5. Total Revenue:
o The SUM() function calculates the total revenue by multiplying Quantity by SalePrice for each
sale record and summing them up.
1 Draw an E-R diagram and convert entities and relationships to a relation table for a given scenario.
(Two assignments shall be carried out i.e. consider two different scenarios (e.g. bank, college)
6 Perform the following: a. Creating Tables (With and Without Constraints(Key/Domain), b. Creating Tables
7 For a given set of relation schemes, create tables and perform the following Queries:
a. Simple Queries
8 For a given set of relation schemes, create tables and perform the following Queries: Inner Join,
a. Creating Views ,
b. Dropping views,
11 Given the table EMPLOYEE (EmpNo, Name, Salary, Designation, DeptID) write a cursor to select the
12 For a given set of related tables perform the following: a. Begin Transactions b. End Transaction
13For a given set of related tables perform the following: a. Create roles b. Assign Privileges c. Revoke Privileges
14 Write a Pl/SQL program using a FOR loop to insert ten rows into a database table.
15 Perform the following: Inserting/Updating/Deleting Records in a Table, Saving (Commit) and Undoing (rollback)