0% found this document useful (0 votes)
25 views13 pages

CIE 1 DBMS Lab

o there are 2 things involved here one is interactive system or software specifically computer software that are interactive. So we are going to focus here entirely on software that is interactive what is interactive software? We will soon learn about those second concepts that are important here is that word engineering. So here we actually refer to the fact that such software can be developed in a very systematic manner involving stages and we are going to learn about those stages
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)
25 views13 pages

CIE 1 DBMS Lab

o there are 2 things involved here one is interactive system or software specifically computer software that are interactive. So we are going to focus here entirely on software that is interactive what is interactive software? We will soon learn about those second concepts that are important here is that word engineering. So here we actually refer to the fact that such software can be developed in a very systematic manner involving stages and we are going to learn about those stages
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/ 13

Sona College of Technology(Autonomous)

Department of Computer Science and Engineering


U19CS405 -Database Management Systems Laboratory

LAB CIE1
01-04-2024

1. Consider the following database consisting of the following tables:


Employee (ssn, first name, last name, gender, designation, doj, address)
Employee-salary (ssn, basicpay, DA, TA, pay)
Department (did, dname, mgrssn)
Employee-department (ssn, deptid)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)
i. For each employee, retrieve the employee first name and last name
ii. Display the distinct department count.
iii. Retrieve all the information about employees working in Research department
including the department information.
iv. Retrieve the doj, address of employees who work for Research department using
joins.
v. Update the basic pay of each employee with 5%
vi. Identify relations for join and execute join and then display the results.
vii. Illustrate update operation on anyone of the table.
viii. Add new attribute on existing table
ix. Remove anyone attribute from the table

2. Consider the following database consisting of the following tables:


Employee (ssn, firstname, lastname, gender, designation, doj, address)
Employee-salary (ssn, basicpay, DA, TA, pay)
Department (did, dname, mgrssn)
Employee-department (ssn, deptid)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)
i. Retrieve the employee name in the ascending order.
ii. Find the maximum salary in each department
iii. Retrieve all the information about employees working in Science department
including the department information.
iv. Retrieve the doj, address of employees who work for Research department using
joins.
v. Update the basic pay of each employee with 5%
vi. Identify relations for join and execute join and then display the results.
vii. Illustrate update operation on anyone of the table.
viii. Add new attribute on existing table
ix. Identify and add all possible constraints
x. Remove anyone attribute from the table

3. Consider the following database consisting of the following tables:


Employee (ssn, firstname, lastname, gender, designation, doj, address)
Employee-salary (ssn, basic pay, DA, TA, pay)
Department (did, dname, mgrssn)
Employee-department (ssn, deptid)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)
i. For each employee, retrieve the employee ssn, first name and dname
ii. Retrieve the doj, address of employees who work for Research department
iii. Display the employee ssn who earning second lowest basic pay
iv. Display the department having employee count > 2.
v. Update the DA and TA to 3% if the basic pay is >4000.
vi. Identify relations for join and execute join and then display the results.
vii. Illustrate update operation on anyone of the table.
viii. Remove an attribute on existing table
ix. Identify and add all possible constraints

4. Consider the following database consisting of the following tables:


Employee (empid, employeename, street, city)
Works (empid, compid, salary, doj)
Company (compid, companyname, city)
Manager (empid, managerid)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)
i. Find the names, streets and cities of residence of all employees who work for
CISCO and earn more than 1,80,000.
ii. Find those companies whose employees earn a higher salary on average than the
average salary at Infosys.
iii. Find the names of all employee who earn more than every employee of ‘Infosys’.
iv. Find all employees in database who live in the city Chennai and under the
manager Karthi.
v. Find the employee name who earning the second highest salary.
vi. Identify relations for join and execute join and then display the results.
vii. Illustrate update operation on anyone of the table.
viii. Remove an attribute on existing table
ix. Identify and add all possible constraints

5. Consider the following database consisting of the following tables:


Employee (empid, employeename, street, city)
Works (empid, compid, salary, doj)
Company (compid, companyname, city)
Manager (empid, managerid)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)
i. Find the employees in the database who live in the same cities as the companies
for which they work.
ii. Find all employees who earn more than the average salary of all employees of that
company.
iii. Write the query to find the employee name who works in the Compay ‘XYX’
using joins.
iv. Find the no. of employees in each company.
v. Update the salary of the employee with 7%.
vi. Identify relations for join and execute join and then display the results.
vii. Illustrate update operation on anyone of the table.
viii. Add attribute on existing table
ix. Identify and add all possible constraints

6. Consider the following database consisting of the following tables:


Department (deptid, deptname)
Student (rollno, name, gender, mark1, mark2, mark3, dept id)
Staff (staff id, name, designation, qualification, dept id)
Tutor (rollno, staff id)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)
i. Display the student details who come under the tutor ship of the given staff name
“X”.
ii. How many students are there in CSE department?
iii. Display the staff details who work in CSE department.
iv. Display the student details who got average >85.
v. Display the student name who has secured second lowest total w.r.t each
department.
vi. Identify relations for join and execute join and then display the results.
vii. Illustrate update operation on anyone of the table.
viii. Add and remove an attribute on existing table
ix. Identify and add all possible constraints

7. Consider the following database consisting of the following tables:


Department (deptid, deptname)
Student (rollno, name, gender, mark1, mark2, mar3, total, average, deptid)
Staff (staff id, name, designation, qualification, deptid)
Tutor (rollno, staff id)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)
i. Display the student details who got greater than overall average marks of their
department.
ii. Display the staff details who work in CSE department.
iii. How many different designations and departments are there?
iv. Display the no.of. Student under the department ‘cse’.
v. Update the qualification of staff from Assistant Professor to Professor.
vi. Identify relations for join and execute join and then display the results.
vii. Illustrate update operation on anyone of the table.
viii. Add attribute on existing table
ix. Identify and add all possible constraints

8. Consider the following database consisting of the following tables:


Branch (bname, bcity, assets)
Account (ano, starting date, bname, balance)
Customer (cusid, name, address)
Deposit (ano, cusid, bname)
Loan (lno, banme, amt)
Borrower (cusid, lno)
Transaction (ano, amount, mode, date of trans)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)
i. Display the details of the loan whose branch is at ‘Salem’
ii. Find the average account balance at each branch and display only if it is greater
than 10000.
iii. Find the largest account balance in the bank.
iv. Find the names of all customers who have a loan with lno and amount(joins)
v. Update the loan amount to 5% if the loan amount is greater than 50000
vi. Identify relations for join and execute join and then display the results.
vii. Illustrate update operation on anyone of the table.
viii. Add attribute on existing table
ix. Identify and add all possible constraints
9. Consider the insurance database given below. The primary keys are made bold and the
data types are specified.
PERSON( driver_id:string , name:string , address:string )
CAR( regno:string , model:string , year:int )
ACCIDENT( report_number:int , accd_date:date , location:string )
OWNS( driver_id:string , regno:string )
PARTICIPATED( driver_id:string , regno:string , report_number:int ,
damage_amount:int)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)
i. Find the person who owns more than two cars.
ii. .Find the total damage amount made by the driver name “XYZ”
iii. Update the damage amount to 25000 for the car with a specific Regno in the ACCIDENT
table with report number 12.
iv. Add a new accident to the database.
v. Find the total number of people who owned cars that were involved in accidents in the
year 2023.
vi. Identify relations for join and execute join and then display the results.
vii. Illustrate update operation on anyone of the table.
viii. Add attribute on existing table
ix. Identify and add all possible constraints

10. Consider the following database for a banking enterprise.


account(account_number, branch_name, balance)
branch (branch_name, branch_city, assets)
customer (customer_name customer_street, customer_city)
loan (loan_number, branch_name, amount)
depositor((customer_name, account_number)
borrower(customer_name, loan_number)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)
i. List all branch names and their assests
ii. List all accounts of Brooklyn branch
iii. Change the size of the branch_city to varchar(20).
iv. For all customers who have a loan from the bank, find their names and loan numbers with
the attribute loan_number replaced by loan_id.
v. Select the names of customers who have a loan at the bank, and whose names are neither
Smith nor Jones
vi. Identify relations for join and execute join and then display the results.
vii. Illustrate update operation on anyone of the table.
viii. Add attribute on existing table
ix. Identify and add all possible constraints

11. Consider the following database consisting of the following tables:


Party (pid, pname, leader)
Constituency (cid, cname)
Contestant (ctid, ctname, ctaddr)
Election (ctid, number of votes, pname, cname)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)
i. Display the contestant details if they secured greater than 10,000 votes.
ii. Find the number of contestants, constituency wise.
iii. Display the winner details in each constituency.
iv. Display the difference of votes in each constituency w.r.t first and second
position.
v. Find the contestant who got the least number of votes
vi. Apply join condition on election and contestant relation and retrieve information
vii. Illustrate update operation on anyone of the table.
viii. Add attribute on existing table
ix. Identify and add all possible constraints

12. Consider the following database consisting of the following tables:


Employee (ssn, first name, last name, gender, designation, doj, address)
Employee-salary (ssn, basic pay, DA, TA, pay)
Department (did, dname, mgrssn)
Employee-department (ssn, deptid)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)
i. For each employee, retrieve the employee ssn, first name and dname
ii. Retrieve the doj, address of employees who work for Research department
iii. Create view on this having subset of attributes and then perform update operation
on view.
iv. Find out average salary of an employee according to their department
v. Display the employee according to their joining date in descending order.
vi. Apply join condition on employee and employee-salary relation and retrieve
information
vii. Illustrate update operation on anyone of the table.
viii. Add attribute on existing table
ix. Identify and add all possible constraints

13. Consider the following database consisting of the following tables:


Department (dept id, dept name)
Student (rollno, name, gender, mark1, mark2, mark3, dept id)
Staff (staff id, name, designation, qualification, dept id)
Tutor (rollno, staff id)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)
i. Display the student details who come under the tutor ship of the given staff name
“X”.
ii. How many students are there in CSE department?
iii. Count the number of students for each tutors.
iv. Find out minimum and maximum mark of each department
v. Apply join condition on student and tutor relation and retrieve information
vi. Illustrate update operation on anyone of the table.
vii. Add attribute on existing table
viii. Identify and add all possible constraints

15. Consider the insurance database given below. The primary keys are made
bold and the data types are specified.
PERSON( driver_id, name, address)
CAR( regno , model, year)
ACCIDENT( report_number, accd_date , location )
OWNS( driver_id , regno )
PARTICIPATED( driver_id , regno, report_number ,damage_amount)
i. Create the above tables by properly specifying the primary keys and foreign keys.
Enter at least five tuples for each relation.
ii. Demonstrate how you update the damage amount for the car with specific regno in
the accident with report number 12 to 25000.
iii. Add a new accident to the database.
iv. Find the total number of people who owned cars that were involved in accidents in
the year 2022.
v. Find the number of accidents in which cars belonging to a specific model were
involved.
vi. Identify and add all possible constraints
vii. Create a view which consists of person details who own a car swift.

16. Consider the following relations for an order processing database application in a company.
CUSTOMER( custno:int , cname:string , city:string )
ORDER( orderno:int , odate:date , custno:int , ord_amt:int )
ORDER_ITEM( orderno:int , itemno:int , quantity:int )
ITEM( itemno:int , unitprice:int )
SHIPMENT( orderno:int , warehouseno:int , ship_date:date )
WAREHOUSE( warehouseno:int , city:string )

(Create the tables with necessary primary and foreign key)


(Enter at least five records for each relation)

i. Create the above tables by properly specifying the primary keys and foreign keys.
Enter at least five tuples for each relation.
ii. Produce a listing: custname , No_of_orders , Avg_order_amount , where the middle
column is the total number of orders by the customer and the last column is the average
order amount for that customer.
iii. List the order no for orders that were shipped from all the warehouses that the company
has in a specific city.
iv. Demonstrate the deletion of an item from the ITEM table and demonstrate a method of
handling the rows in the ORDER_ITEM table that contains this particular item.
v. Identify and add all possible constraints
vi. Demonstrate the use of DCL and TCL commands in it

17. Consider the following database of student enrollment in courses and books adopted for that
course.
STUDENT( regno:string , name:string , major:string , bdate:date )
COURSE( courseno:int , cname:string , dept:string )
ENROLL( regno:string , courseno:int , sem:int , marks:int )
BOOK_ADOPTION( courseno:int , sem:int , book_isbn:int )
TEXT( book_isbn:int , book_title:string , publisher:string , author:string )

(Create the tables with necessary primary and foreign key)


(Enter at least five records for each relation)

i. Create the above tables by properly specifying the primary keys and foreign
keys.Enter atleast five tuples for each relation.
ii. Demonstrate how you add a new text book to the database and make this book to be
adopted by some department.
iii. Produce a list of text books ( includes courseno , book_isbn , book_title ) in the
alphabetical order for courses offered by the 'CSE' department that use more than two
books.
iv. List any department that has all its books published by a specific publisher.
v. Identify and add all possible constraints
vi. Demonstrate the use of DCL and TCL commands in it

18. The following are maintained by abook dealer.


AUTHOR( author_id:int , name:string , city:string , country:string )
PUBLISHER( publisher_id:int , name:string , city:string , country:string )
CATALOG( book_id:int , title:string , author_id:int , publisher_id:int ,
category_id:int , year:int ,price:int)
CATEGORY( category_id:int , description:string )
ORDER_DETAILS( order_no:int , book_id:int , quantity:int )
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)

i. Create the above tables by properly specifying the primary keys and foreign keys
ii. Enter at least five tuples for each relation.
iii. Give the details of the authors who have 2 or more books in the catalog and the price
of the books is greater than the average price of the books in the catalog and the year
of publication is after 2000.
iv. Find the author of the book that has maximum sales.
v. Demonstrate how you increase the price of books published by a specific publisher by
10%.
vi. Add a new constraint.
vii. Find the name of the book which has highest number of order along with the total
cost.
viii. Create a view which consists of the details of the author who published in the Wiley
publications.
ix. Identify and add all possible constraints
x. Create index on anyone table and use it.

19. Consider the following database for a banking enterprise.


BRANCH( branch_name:string , branch_city:string , assets:real )
ACCOUNT( accno:int , branch_name:string , balance:real )
DEPOSITOR( customer_name:string , accno:int )
CUSTOMER( customer_name:string , customer_street:string , customer_city:string )
LOAN( loan_number:int , branch_name:string , amount:real )
BORROWER( customer_name:string , loan_number:int )

(Create the tables with necessary primary and foreign key)


(Enter at least five records for each relation)

i. Create the above tables by properly specifying the primary keys and foreign keys.
ii. Enter at least five tuples for each relation.
iii. Find all the customers who have at least two accounts at the main branch.
iv. Find all the customers who have an account at all the branches located in a specific city
v. Demonstrate how you delete all account tuples at every branch located in a specific city.
a. HRA = 50% of Basic
b. DA=20% of Basic
c. PF=6% of Basic
d. Salary = Basic+DA+HRA-PF
vi. Identify and add all possible constraints
vii. Create index on anyone table and use it.

20. Implement the Bank Database and execute the given queries

ACCOUNT(account_number, branch_name, balance)


BRANCH (branch_name, branch_city, assets)
CUSTOMER (customer_name customer_street, customer_city)
LOAN (loan_number, branch_name, amount)
DEPOSITOR((customer_name, account_number)
BORROWER(customer_name, loan_number)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)

i.
List all branch names and their assests
ii.
List all accounts of Chennai branch
iii.
Change the assests of Salem branch to 340000000.
iv.
Waive off all the loans with amount < 10000.
v.
Find the customer names, loan numbers, and loan amounts, for all loans at the Salem
branch.
vi. List loan data, ordered by decreasing amounts, then increasing loan numbers.
vii. Find all the customers who have both a loan and an account at the Bangalore branch
viii. Find the average account balance of those branches where the account balance is
greater than Rs. 15,000.

21. Implement the Bank Database and execute the given queries

ACCOUNT(account_number, branch_name, balance)


BRANCH (branch_name, branch_city, assets)
CUSTOMER (customer_name customer_street, customer_city)
LOAN (loan_number, branch_name, amount)
DEPOSITOR((customer_name, account_number)
BORROWER(customer_name, loan_number)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)

i.
Find all the bank customers having a loan, an account, or both at the bank.
ii.
Find all customers who have an account but no loan at the bank.
iii.
Find the average account balance at the Salem branch.
iv.
Find the average account balance at each branch.
v.
Find all loan numbers that appear in the loan relation with null values for amount.
Find the names of all customers whose street address includes the substring ‘Main’.
vi.
vii.
Find all customers who do have a loan at the bank, but do not have an account at the
bank.
viii. Find the average account balance of those branches where the account balance is greater
than Rs. 12,00,000
ix. Identify and add all possible constraints
x. Demonstrate database transaction control language commands

22. Implement the Bank Database and execute the given queries

ACCOUNT(account_number, branch_name, balance)


BRANCH (branch_name, branch_city, assets)
CUSTOMER (customer_name customer_street, customer_city)
LOAN (loan_number, branch_name, amount)
DEPOSITOR((customer_name, account_number)
BORROWER(customer_name, loan_number)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)

i. List all loans with amount > 10.00.000.


ii. List all accounts of Trichy branch with balance < 10000.
iii. Transfer Rs. 100 from account A-101 to A-215.
iv. Delete the accounts and loans of Erode branch.
v. For all customers who have a loan from the bank, find their names, loan numbers, and
loan amount.
vi. Find the names of all customers whose street address includes the substring ‘Main’
vii. Select the names of customers who have a loan at the bank, and whose names are neither
Smith nor Jones
viii. Find the average account balance of those branches where the account balance is greater
than Rs. 1200
ix. Identify and add all possible constraints
x. Demonstrate database transaction control language commands

23. Implement the Bank Database and execute the given queries

ACCOUNT(account_number, branch_name, balance)


BRANCH (branch_name, branch_city, assets)
CUSTOMER (customer_name customer_street, customer_city)
LOAN (loan_number, branch_name, amount)
DEPOSITOR((customer_name, account_number)
BORROWER(customer_name, loan_number)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)

i. List all accounts of Madurai branch with balance < 10000.


ii. List Numbers of accounts with balances between 700 and 900
iii. Transfer the accounts and loans of Madurai branch to Trichy branch.
iv. Find all the bank customers having both a loan and an account at the bank
v. Find the number of branches of the bank.
vi. Find the average balance for each customer who lives in Harrison and has at least three
accounts.
vii. Find the names of all branches that have assets greater than those of at least one branch
located in Trichy .
viii. Find the maximum across all branches of the total balance at each branch
ix. Identify and add all possible constraints
x. Demonstrate database transaction control language commands

24. Implement the Bank Database and execute the given queries

ACCOUNT(account_number, branch_name, balance)


BRANCH (branch_name, branch_city, assets)
CUSTOMER (customer_name customer_street, customer_city)
LOAN (loan_number, branch_name, amount)
DEPOSITOr((customer_name, account_number)
BORROWER(customer_name, loan_number)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)

i. List all branch names and their assests


ii. List all accounts of Brooklyn branch
iii. Change the size of the branch_city to varchar(20).
iv. For all customers who have a loan from the bank, find their names and loan numbers with
the attribute loan_number replaced by loan_id.
v. Select the names of customers who have a loan at the bank, and whose names are neither
Santhosh nor James.
vi. Find the number of depositors for each branch (Use distinct).
vii. Find the names of all branches that have an asset value greater than that of each branch in
Trichy .Find the maximum across all branches of the total balance at each branch
viii. Identify and add all possible constraints
ix. Demonstrate database data control language commands

25. Implement the Bank Database and execute the given queries

ACCOUNt(account_number, branch_name, balance)


BRANCH (branch_name, branch_city, assets)
CUSTOMER (customer_name customer_street, customer_city)
LOAN (loan_number, branch_name, amount)
DEPOSITOR((customer_name, account_number)
BORROWER(customer_name, loan_number)
(Create the tables with necessary primary and foreign key)
(Enter at least five records for each relation)

i. List all loans with amount > 1000.


ii. List all accounts of Salem branch with balance < 10000.
iii. Add a column phoneNo to customer table.
iv. Find all customers who have an account but no loan at the bank.
v. Find those branches where the average accounts balance is more than Rs. 1200.
vi. Find all customers who have both an account and a loan at the bank
vii. Find all customers who have at most one account at the Chennai branch
viii. Find the maximum across all branches of the total balance at each branch
ix. Identify and add all possible constraints
x. Demonstrate database data control language commands

You might also like