0% found this document useful (0 votes)
43 views26 pages

DBMS Practical File

The document is a lab file for a Database Management Systems course, detailing various assignments and experiments related to database design and SQL queries. It includes tasks such as creating ER diagrams, implementing database schemas, performing SQL operations, and executing queries on sample databases like COLLEGE and COMPANY. Each assignment focuses on different aspects of database management, including data manipulation, integrity constraints, and privilege management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views26 pages

DBMS Practical File

The document is a lab file for a Database Management Systems course, detailing various assignments and experiments related to database design and SQL queries. It includes tasks such as creating ER diagrams, implementing database schemas, performing SQL operations, and executing queries on sample databases like COLLEGE and COMPANY. Each assignment focuses on different aspects of database management, including data manipulation, integrity constraints, and privilege management.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Introduction to Database Management

Systems Lab File


Course Code: ENBC252

Submitted To: Submitted By:


Dr. Preeti Rathi Yashika Kaimwaal
Assistant Professor 2301840012
SOET B.Sc.(H) Data Science
INDEX
S.No. EXPERIMENTS Teacher’s
Signature
Consider following databases and draw ER diagram and convert entities
1 and relationships to relation table for a given scenario:
COLLEGE DATABASE:
STUDENT (USN, SName, Address, Phone, Gender)
SEMSEC (sSSID, Sem, Sec)
CLASS (USN, SSID)
SUBJECT (Subcode, Title, Sem, Credits)
IAMARKS (USN, Subcode, SSID, Test1, Test2, Test3, FinalIA)

Consider following databases and draw ER diagram and convert entities


2 and
relationships to relation table for a given scenario:
COMPANY DATABASE:
EMPLOYEE (SSN, Name, Address, Sex, Salary, SuperSSN, DNo)
DEPARTMENT (DNo,
DName, MgrSSN, MgrStartDate)
DLOCATION (DNo,DLoc)
PROJECT (PNo, PName, PLocation, DNo)
WORKS_ON (SSN, PNo, Hours)
Database Schema for a customer-sale scenario
3 Customer(Cust id : integer, cust_name: string)
Item(item_id: integer, item_name: string, price: integer)
Sale(bill_no:integer,bill_data:date,cust_id: integer, item_id: integer,
qty_sold: integer)
For the above schema, perform the following—
1. Create the tables with the appropriate integrity constraints.
2. Insert around 10 records in each of the tables.
3. List all the bills for the current date with the customer names and item
numbers.
4. List the total Bill details with the quantity sold, price of the item and the
final
amount.
5. List the details of the customer who have bought a product which has a
price>200.
6. Give a count of how many products have been bought by each customer
7. Give a list of products bought by a customer having cust_id as 5.
8. List the item details which are sold as of today.
9. Create a view which lists out the bill_no, bill_date, cust_id, item_id, price,
qty_sold,
amount.
10. Create a view which lists the daily sales date wise for the last one week
Consider the following table:
4 Table: CLASS
ID Name
1 Bravo
2 Alex
4 Cheng

Give the output of the following SQL script:


• INSERT INTO class VALUES (5,’Rahul’);
• COMMIT;
• UPDATE class SET name = ‘Abhijeet’ WHERE id= ‘5’;
• SAVEPOINT A;
• INSERT INTO class VALUES (6, ‘Chris’);
• SAVEPOINT B;
• INSERT INTO class VALUES (7, ‘Bravo’);
• SAVEPOINT C
• SELECT * FROM class;
• ROLLBACK TO B;
• SELECT * FROM class;
• ROLLBACK TO A;
(Exercise on retrieving records from the table)
5 EMPLOYEES
Phone_Number,
(Employee_Id, First_Name, Last_Name, Email,

Hire_Date, Job_Id, Salary, Commission_Pct, Manager_Id, Department_Id)


( a) Find out the employee id, names, salaries of all the employees
( b) List out the employees who works under manager 100
( c) Find the names of the employees who have a salary greater than or equal
to 4800
( d) List out the employees whose last name is ‘AUSTIN’
( e) Find the names of the employees who works in departments 60,70 and
80
( f ) Display the unique Manager_Id.
(Exercise on updating records in table)
6 Create Client_master with the following fields
(ClientNO, Name, Address, City, State, bal_due)
( a ) Insert five records
( b ) Find the names of clients whose bal_due> 5000 .
( c ) Change the bal_due of ClientNO “ C123” to Rs. 5100
( d ) Change the name of Client_master to Client12.
( e ) Display the bal_due heading as “BALANCE”
Rollback and Commit commands Create Teacher table with the following
7 fields
(Name, DeptNo, Date of joining, DeptName, Location, Salary)
( a ) Insert five records
( b ) Give Increment of 25% salary for Mathematics Department .
( c ) Perform Rollback command
(d)GiveIncrementof15%salaryforCommerce Department
( e ) Perform commit command
(Exercise on order by and group by clauses) Create Sales table with the
8 following fields
( Sales No, Salesname, Branch, Salesamount, DOB)
( a ) Insert five records
( b ) Calculate total salesamount in each branch
( c ) Calculate average salesamount in each branch ( d ) Display all the
salesmen, DOB who
are born in the month of December as day in character format i.e. 21-Dec-09
( e ) Display the name and DOB of salesman in alphabetical order of the
month.
Consider the following tables namely “DEPARTMENTS” and
9 “EMPLOYEES” Their schemas
are as follows,
Departments ( dept _no , dept_ name , dept_location );
Employees ( emp_id , emp_name , emp_salary,dept_no);
a) Develop a query to grant all privileges of employees table into
departments
table
b) Develop a query to grant some privileges of employees table into
departments table
c) Develop a query to revoke all privileges of employees table from
departments
table
d) Develop a query to revoke some privileges of employees table from
departments table
e) Write a query to implement the save point.
Using the tables “DEPARTMENTS” and “EMPLOYEES” perform
10 the following queries
a) Display the employee details, departments that the departments are same
in
both the emp and dept.
b) Display the employee name and Department name by implementing a left
outer
join.
c) Display the employee name and Department name by implementing a
right outer
join.
d) Display the details of those who draw the salary greater than the average
salary
Assignment-1
Consider following databases and draw ER diagram and
convert entities and relationships to relation table for a given
scenario:
COLLEGE DATABASE:
STUDENT (USN, SName, Address, Phone, Gender)
SEMSEC (sSSID, Sem, Sec)
CLASS (USN, SSID)
SUBJECT (Subcode, Title, Sem, Credits)
IAMARKS (USN, Subcode, SSID, Test1, Test2, Test3,
FinalIA)
Assignment-2
Consider following databases and draw ER diagram and
convert entities and
relationships to relation table for a given scenario:
COMPANY DATABASE:
EMPLOYEE (SSN, Name, Address, Sex, Salary, SuperSSN,
DNo) DEPARTMENT (DNo,
DName, MgrSSN, MgrStartDate)
DLOCATION (DNo,DLoc)
PROJECT (PNo, PName, PLocation, DNo)
WORKS_ON (SSN, PNo, Hours)
Assignment-3
Problem Statement:
Database Schema for a customer-sale scenario
Customer (Cust id : integer, cust_name: string)
Item (item_id: integer, item_name: string, price: integer)
Sale (bill_no:integer,bill_data:date,cust_id: integer, item_id:
integer, qty_sold: integer)
For the above schema, perform the following—
1. Create the tables with the appropriate integrity
constraints.
2. Insert around 10 records in each of the tables.

3. List all the bills for the current date with the customer
names and item numbers.
4. List the total Bill details with the quantity sold, price of
the item and the final amount.

5. List the details of the customer who have bought a


product which has a price>200.
6. Give a count of how many products have been bought by
each customer.

7. Give a list of products bought by a customer having


cust_id as 5.

8. List the item details which are sold as of today.


9. Create a view which lists out the bill_no, bill_date, cust_id,
item_id, price, qty_sold, amount.

10. Create a view which lists the daily sales date wise for the
last one week
ASSIGNMENT 4
Consider the following table:
Table: CLASS
ID Name
1 Bravo
2 Alex
4 Cheng

Give the output of the following SQL script:


• INSERT INTO class VALUES (5,’Rahul’);
• COMMIT;
• UPDATE class SET name = ‘Abhijeet’ WHERE id= ‘5’;
• SAVEPOINT A;
• INSERT INTO class VALUES (6, ‘Chris’);
• SAVEPOINT B;
• INSERT INTO class VALUES (7, ‘Bravo’);
• SAVEPOINT C
• SELECT * FROM class;
• ROLLBACK TO B;
• SELECT * FROM class;
• ROLLBACK TO A;
ASSIGNMENT 5
EMPLOYEES (Employee_Id, First_Name, Last_Name,
Email, Phone_Number, Hire_Date, Job_Id, Salary,
Commission_Pct, Manager_Id, Department_Id)
(a) Find out the employee id, names, salaries of all the
employees.

(b) List out the employees who works under manager


100

(c) Find the names of the employees who have a salary


greater than or equal to 4800
(d) List out the employees whose last name is ‘AUSTIN’

(e) Find the names of the employees who works in


departments 60, 70 and 80.

(f) Display the unique Manager_Id.


ASSIGNMENT 6
Create Client_master with the following fields
(ClientNO, Name, Address, City, State, bal_due)
(a) Insert five records

(b) Find the names of clients whose bal_due> 5000 .

(c) Change the bal_due of ClientNO “ C123” to Rs. 5100.


(d) Change the name of Client_master to Client12.

(e) Display the bal_due heading as “BALANCE”


ASSIGNMENT 7
Rollback and Commit commands Create Teacher table with the
following fields
(Name, DeptNo, Date of joining, DeptName, Location, Salary)
(a) Insert five records
(b) Give Increment of 25% salary for Mathematics
Department.
(c) Perform Rollback command
(d) GiveIncrementof15%salaryforCommerce
Department
(e) Perform commit command
ASSIGNMENT 8
Create Sales table with the following fields
(Sales No, Salesname, Branch, Salesamount, DOB)
(a) Insert five records

(b) Calculate total salesamount in each branch


(c) Calculate average salesamount in each branch

(d) Display all the salesmen, DOB who are born in the month
of December as day in character format i.e. 21-Dec-09

(e) Display the name and DOB of salesman in alphabetical


order of the month.
ASSIGNMENT 9
Consider the following tables namely “DEPARTMENTS”
and “EMPLOYEES” Their schemas are as follows:
Departments ( dept _no , dept_ name , dept_location );
Employees ( emp_id , emp_name , emp_salary,dept_no);

1. Develop a query to grant all privileges of employees table


into departments table
2. Develop a query to grant some privileges of employees
table into departments table
3. Develop a query to revoke all privileges of employees table
from departments table
4. Develop a query to revoke some privileges of employees
table from departments table
5. Write a query to implement the save point.
ASSIGNMENT 10
Using the tables “DEPARTMENTS” and “EMPLOYEES”
perform the following queries

a) Display the employee details, departments that the


departments are same in both the emp and dept.

b) Display the employee name and Department name by


implementing a left outer join.
c) Display the employee name and Department name by
implementing a right outer join.

d) Display the details of those who draw the salary greater


than the average salary

You might also like