DBMS Lab QB
DBMS Lab QB
Create the following tables with given attributes having appropriate data
type and specify the necessary primary and foreign key constraints:
Customer (Custid, Custname, Age, phone)
Loan (Loanid, Amount, Custid, EMI)
a) List the name of the customers who have taken loan for more than Rs.50,000.
b) List the Customer id of those who have no loan.
c) List the total count of loan availed.
d) Create a procedure to print the Amount and Custid when the Loanid is given as
input. Handle Exceptions.
Table creation with Appropriate Constraints and Data Type (15)
2. Create the following tables with given attributes having appropriate data
type and specify the necessary primary and foreign key constraints:
Employee (EmpId, Empname, Sal, Deptno)
Dept (Deptno, Dname, Loc,DeptmanagerId)
a) List the count of Employees and average salary of each department.
b) List the employee name, department name and the salary of all the employees.
c) Display the Employee name and the respective department manager name.
d) Create a function to return the salary of the employee when Empid is given as
input parameter. Handle Exceptions.
Table creation with Appropriate Constraints and Data Type (15)
4. Create the following tables with given attributes having appropriate data
type and specify the necessary primary and foreign key constraints:
User (Userid, Name, Dept, Bookid, Accdate)
Book (Bookid, Book_name, Author, Publication, Price)
a) List the name of the user who had accessed the costliest book.
b) List the userid and count of books accessed by the user.
c) List the books published by Wiley publisher.
d) Write a PL/SQL program to print the details of the book when Bookid is given as
input. Handle appropriate exceptions.
7. Create the following tables with given attributes having appropriate data
type and specify the necessary primary and foreign key constraints:
Product (Prodid, Prodesc, Price, Stock)
Sales (Salesid, Prodid, qty)
a) Add a column reorder in Product table having value 50 for all products.
b) Create a Login form to validate a user.
c) Create a Form using Menus to
(i) Add a product.
(ii) Delete a product.
8. Create the following tables with given attributes having appropriate data
type and specify the necessary primary and foreign key constraints:
Product (Prodid, Prodesc, Price, Stock)
Sales (Salesid, Prodid, qty)
a) Add a column reorder in Product table having value 50 for all products.
b) Display the Sales Report.
c) Create an application for
i) User Login &
ii) checking the availability of a product in a stock.
11. Create an application for Quiz system. Create the necessary table(s) with
attributes having appropriate data type and specify the necessary key constraints.
12. Create the following tables with given attributes having appropriate data
type and specify the necessary primary and foreign key constraints:
Marks(Regno,Name , Dept, Subj1,Subj2,Subj3)
a) Add a column Total in student table and update the Total field with the sum of 3
subject Marks.
b) Find the second maximum total in the table.
c) Display the name of the student with maximum total.
d) Write a PL/SQL program to display the report sheet of the students using
cursors.
14. Create the following tables with the mapping given below.
stu_details (reg_no, stu_name, DOB, address, city)
mark_details (reg_no, mark1, mark2, mark3, total)
(a) Alter the table mark_details to add a column average with data type as long.
(b) Display the months between the DOB and till date.
(c) Using alter command drop the column address from the table stu_details.
(d) Write a PL/SQL program to find the sum & average marks of all the student using
procedures.
15. Create the following tables with the mapping given below.
Employee (Empno, Ename, Job, MgrId, DoB, DoJ, Sal, Comm, Deptno)
Department (Dname, Deptno, Dloc)
(a) Display the Emp no, name, salary and experience of each employee ordered by
salary (highest to lowest)
(b) List the names of the employee working for �Marketing� Department.
(c) List the names of the employees born in the current month.
(d) Write a PL/SQL function to display the details of the employee when Employee no
given as input. Handle Exceptions.
16.
17. (a) Create a table Student (Regno, name , Mark) and insert records. Write a
PL/SQL function to print the grade of the Student. Obtain student mark as input
from the main program. Check for the following condition: if the input mark ranges
91-100 then Grade A, 81-90 then Grade B, 71-80 then Grade C, 60-70 then Grade D and
<60 Grade E.
(b) Develop an application for Banking System. Design a Database schema and create
necessary tables and forms.
18. (a)Write a PL/SQL program to print the payslip of the employee. Create a
table Employee (Id, Name, Basicpay, DOB,Dept).Obtain Employeeid as input from the
main program. (Basic pay +DA+HRA-TAX-DED). Assume the Allowances and Deduction %.
(b) Develop an application for Employee payroll processing System to add, delete,
update employee particulars and generate payslip with the employee table created in
19. (a) Create a table Bank (acc_no, name, balance) and insert records into the
table. Write a PL/SQL program for the Bank table to notify the user if the account
balance is less than 500. Obtain account no as input. Handle Exceptions.
(b) Develop an application for inventory management System. Design a Database
schema and Create necessary tables and forms.
20. (a) Create the table Book (acc_no, username, bookno, days) and insert few
records into the table. Write a PL/SQL Program to calculate the fine for library
book (Rs 5 /day). (Hint: fine =days*5). Obtain account no as input. Handle
Exceptions.
(b). Design a Database schema for Library management System. Develop an application
for managing book details in Library management System .
-----------------------------------------------------------------------------------
-------------------------------------
1. Consider the Insurance database given below.
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. Specify the primary keys and foreign keys and enter at least five tuples for
each relation.
ii. Update the damage amount for the car with specific regno in the accident with
report number 1025.
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 2018.
v. Find the number of accidents in which cars belonging Wagon R were involved.
4. Create the student database with the following tables and do the following:
assessment(reg_no,name, mark1, mark2, mark3, total)
dept_details (dept_no, dept_name, location).
i. Using alter command drop the column location from the table dept_details.
ii. Display all dept_name along withdept_no.
iii. Drop the table dept_details.
iv. Write a PL/SQL Trigger to verify the data before insertion on assessment
table.
5. Consider the following Tables for a bus reservation system application:
BUS (ROUTENO, SOURCE, DESTINATION)
PASSENGER (PID, PNAME, DOB, GENDER)
BOOK_TICKET (PID, ROUTENO, JOURNEY_DATE, SEAT_NO)
i. Include constraint that DOB of passenger should be after 2000
ii. Display the passengers who had booked the journey from Mumbai to Chennai on
02-Feb-2019
iii. List the details of passengers who have traveled more than three times on the
same route.
iv. Create a View that displays the RouteNo, source, destination and journey_date
which moves from Chennai to Delhi.
v. In the above created procedure, include exceptions to display "No ticket
booked on specified date" for a given journey_date.
12. Create the student database with the following tables and do the following:
mark_details(reg_no,name, mark1, mark2, mark3, total)
dept_details (dept_no, dept_name, HOD)
stud_details(reg_no,name, dob, address)
i. Using alter command to assign foreign key in mark_details.
ii. Display the address of the students who have secured the top three ranks.
iii. Write a PL/SQL procedure to update the grade according to the marks secured.
13. Create a database for IoT simulator with the following tables.
Device_details (deviceID, devicename, properties)
Connect_status(deviceID, loginTime, logoutTime)
Transaction_details(transID, deviceID, updatedProperties, timeofUpdation)
i. List the details of the devices that are connected in a particular session
ii. Display the details of the device and its property that has been active for
most of the time.
iii. Develop a PL/SQL procedure that deletes the details of the devices that have
been least updated.
16. Create a database for Timetable generation using the following tables:
Faculty_details(FacultyID,FacultyName, dept)
Subject_details(Subcode, subtitle, dept, year)
Subject_allocated(Subcode, year, dept,FacultyID)
Timetable(period, timefrom, timeto, Subcode,year,dept)
i. Display the timetable of individual faculty
ii. Display the timetable of each class separately
iii. Display the timetable of particular subject
iv. Develop a PL/SQL procedure that displays individual class timetable
17. Create a database for Transportation management system in an organization.
Identify appropriate tables and optimize them using normalization. Develop an
application using front end designing with backend database connectivity.
18. Create a database for listing the academic performance of affliated colleges
under Anna Univeristy. Identify the tables needed. Apply normalization on
identified tables. Develop an application with suitable UI design and finally
generate the academic performance.
19. Develop an application with front end design for Railway Ticket Reservation
system using approriate database system.
20. Develop an application for students attendance tracking and reporting system
with good UI design and database connectivity.
-----------------------------------------------------------------------------------
-----------------------------------------------
Q.NO. EXPERIMENT LIST
1. Create a Table as workers and the details are { S.No, Name, Designation,
Branch }
Perform the following commands:
? Alter the table by adding a column Salary
? Alter the table by modifying the column Name
? Describe the table employee
? Copy the table employee as emp
? Truncate the table
? Delete the Second row from the table
? Drop the table
11. Write a program in PL/SQL to create a cursor displays the name and salary of
each employee in the Employees table whose salary is less than that specified by a
passed-in parameter value.
13. Write a PL/SQL function to calculate the income tax for the given employee:
Conditions:
If pay ? 2,50,000, no tax is charged.
If pay is ? 2,50,001 and ? 5,00,000, 5% of pay is charged as tax.
If pay is ? 5,00,001 and ? 10,00,000, 20% of pay is charged as
tax.
If pay is ? 10,00,001, 30% of pay is charged as tax. .
14. Design a database for an Airline. The database must keep track of customers
and their reservations, flights and their status, seat assignments on individual
flights, and the schedule and routing of future flights.
Your design should include an E-R diagram, a set of relational schemas, and a list
of constraints, including primary-key and foreign-key constraints.
15. Consider a database used to record the marks that students get in different
exams of different courses offerings.
? Construct an ER diagram that models exams as entites, and uses a ternary
relationship, for the database.
? Construct and alternative ER diagram that uses only a binary relationship
between students and course_offerings. Make sure that only one relationship exists
between a particular student and course offering pair, yet you can represent the
marks that a student gets in different exams of a course offering.
16. Consider the employee relational database, Where the primary keys are
underlined.
Employee ( employee_name, street, city)
Works ( employee_name, company_name, salary)
Company ( comapny_name, city)
Manages ( employee_name, manager_name)
? Find all employees in the database who earn more than each employee of Small
Bank Corporation.
? Assume that the companies may be located in several cities. Find all
companies located in every city in which Small Bank Corporation is located.
? Give all managers of first Bank Corporation a 10 percent raise unless the
salary becomes greater than $100,000; in such cases, give only a 3 percent raise.
17. Consider the following relational schema:
Employee( empno, name, office, age )
Books ( isbn, title, authors, publisher )
Loan ( empno, isbn, date )
Write the following queries in SQL:
? Print the names of employees who have borrowed any books published by McGraw-
Hill.
? Print the names of employees who have borrowed all books published by McGraw-
Hill.
? For each publishers, print the names of employees who have borrowed more than
five books of that publisher.
-----------------------------------------------------------------------------------
-----------------------------------------------
1. 1. Create a table �Student� with the following details (table level
constraints)
Rollno number(5) Primary key
Name varchar2(10)
Coursecode number(2) Foreign key (Reference �Course� table)
Mark1 number(3) Check whether values range from 0 to 100
Mark2 number(3) Check whether values range from 0 to 100
2. Create a table �Course� with the following details (table level
constraints)
Ccode number(2) Primary key
Course varchar2(10)
A. Add the field total to table student
B. Insert 5 records into the table. Don�t input values for total field
C. List the student names and their course names
D. Write a PL/SQL block to find whether the given number is odd or even
E. Write a database trigger before delete for each row on table course, delete
corresponding course students from Student table
F. Design and implement a student form to insert and edit the student details.
5. 1. Create a table member with the following fields member code, member
name, phoneno.
2. Create a table book with the following fields bookcode, category code,
bookname, cost.
3. Create a table issue with the following fields membercode, Book code,
Issuedate, Returndate.
A. List all the members names who have taken the book on 8-10-2007.
B. List the member codes of the members who have taken books worth more than Rs.
400.00.
C. Write a PL/SQL block to generate the Fibonacci series
D. Write a PL/SQL block using cursor to display the contents of various tables
based on the options
E. Design and implement a book form to add and display details.
10. 1. Create a table member with the following fields member code, member
name, phoneno.
2. Create a table book with the following fields bookcode, category code,
bookname, cost.
3. Create a table issue with the following fields membercode, Book code,
Issuedate, Returndate.
A. List all the members names who have taken the book on 8-10-2007.
B. Find the total cost of books category wise.
C. Write a PL/SQL block to find whether the given number is odd or even.
D. Write a PL/SQL block to display a particular book details. Display
appropriate message if the book is not found.
E. Design and implement a book store system to add and display book details.
11. 1. Create a table �Student� with the following details (table level
constraints)
Rollno number(5) Primary key
Name varchar2(10)
Coursecode number(2) Foreign key (Reference �Course� table)
Mark1 number(3) Check whether values range from 0 to 100
Mark2 number(3) Check whether values range from 0 to 100
2. Create a table �Course� with the following details (table level constraints)
Ccode number(2) Primary key
Course varchar2(10)
A. Add the field total to table student
B. Insert 5 records into the table. Don�t input values for total field.
C. List the student names and their course names
D. Write a PL/SQL block to find the sum of �n� natural numbers
E. Write a PL/SQL cursor to display the student details
F. Design and implement course management form to add and edit the details.
12. 1. Create a table �Student� with the following details (table level
constraints)
Rollno number(5) Primary key
Name varchar2(10)
Coursecode number(2) Foreign key (Reference �Course� table)
Mark1 number(3) Check whether values range from 0 to 100
Mark2 number(3) Check whether values range from 0 to 100
2. Create a table �Course� with the following details (table level constraints)
Ccode number(2) Primary key
Course varchar2(10)
A. Add the field total to table student
B. Insert 5 records into the table. Don�t input values for total field
C. List the student names and their course names.
D. Write a database trigger to display the total number of records after
inserting a recordinto the table
E. Write a PL/SQL function to display the Fibonacci series.
F. Design and implement a student form to insert and edit the student details.
16. 1. Create a table member with the following fields member code, member
name, phoneno.
2. Create a table book with the following fields bookcode, category code,
bookname, cost.
3. Create a table issue with the following fields membercode, Book code,
Issuedate, Returndate.
A. List all the members names who have taken the book on 8-10-2007.
B. List the member codes of the members who have taken books worth more than Rs.
400.00.
C. Write a PL/SQL block to generate the Fibonacci series
D. Write a database trigger to display the total number of members after
inserting a record into the member table
E. Design and implement a book form to add and delete book details
19. 1. Create a table �Student� with the following details (table level
constraints)
Rollno number(5) Primary key
Name varchar2(10)
Coursecode number(2) Foreign key (Reference �Course� table)
Mark1 number(3) Check whether values range from 0 to 100
Mark2 number(3) Check whether values range from 0 to 100
2. Create a table �Course� with the following details (table level constraints)
Ccode number(2) Primary key
Course varchar2(10)
A. Add the field total to table student
B. Insert 5 records into the table. Don�t input values for total field
C. List the student names and their course names.
D. Write a PL/SQL block to display the Fibonacci series
E. Write a PL/SQL block using cursor to update the total field
F. Design and implement a student form to insert and edit the student details.