You are on page 1of 12

Page 1 of 12

B.E / B.Tech / B.Arch PRACTICAL END SEMESTER EXAMINATIONS, APRIL / MAY 2019

Fourth Semester

CS8481 & DATA BASE MANAGEMENT SYSTEMS LABORATORY

(Regulations 2017)

Time : 3 Hours Answer any one Question Max. Marks 100

(To be filled by the question paper setter)

Database design , Viva-Voce Record Total


Program / Queries Output
creation of table , Data
30 50 10 10 100

1. 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)
create table Customer (Custid int primary key, Custname varchar(20), Age int , phoneno
numeric);
create table loan (Loanid int primary key, Amount float, Custid int, EMI float);
alter table loan add foreign key(Custid) references Customer(Custi d);
insert into Customer values(101,'Vijay',45,783932719),
(102,'Ragav',35,4563728910),
(103,'Hari',29,12390958);
insert into loan values(34532,45000,101,2000),
(18364,55500,102,1500),
(67433,400000,103,2000);
a) List the name of the customers who have taken loan for more than Rs.50,000.
select Custname from Customer as C inner join loan as l on C.Custid=l.Custid where
Amount>50000;
b) List the Customer id of those who have no loan.
insert into Customer values(104,'James',35,983784622);
insert into loan(Loanid,Custid)values(78372,104);
select Custid from loan where Amount is Null;
c) List the total count of loan availed.
select count(loanid) as total from loan;

d) Create a procedure to print the Amount and Custid when the Loanid is given as input.
Handle Exceptions.
Page 2 of 12

3. . Create the following tables with given attributes having appropriate data type and specify the
necessary primary and foreign key constraints:
create table Voter(Voterid number primary key,Votername varchar(20),Gender char(1),Boothid
number,Checkvote int);
create table Booth(Boothid number primary key,Location varchar(20),BIncharge varchar(20));
alter table Voter add foreign key(boothid) references Booth(Boothid);
insert into Booth values(2,'Srivi','Tamil');
insert into Booth values(3,'Trichy','Rajan');
insert into Booth values(15,'Srivi','Anbu');
insert into Booth values(13,'Chennai','Ram');
insert into Voter values(1425,'Siva','M',2,1);
insert into voter values(4663,'Kumar','M',3,0);
insert into Voter values(64757,'Mary','F',15,1);
insert into Voter values(5343,'Anu','F',13,0);
select * from Voter;
select * from Booth;
Voter (VoterId, Votername, Gender, Boothid,Checkvote) checkvote is
1(voted) or 0 (not voted)
Booth (Boothid, Location,BIncharge )
a) (i)List the count of voters in each Booth select count(*) from Voter group by
Boothid;
(ii) List the count of Male voters voted. Select count(*) from Voter checkvote=1 group
by Gender;

b) Display the overall count of voters voted in the election.


select count(*)as voted from Voter where Checkvote=1;
c) Display the Boothid, Location and count of voters voted.

d) Write a function to return the percentage of poll in a booth when boothid is given as
input. Handle Exceptions.
Page 3 of 12

6. Create the following tables with given attributes having appropriate data type and specify the
necessary primary and foreign key constraints:
Customer (Custid, Custname, phno,pan,DOB)
HomeLoan (HLoanid, Amount, Custid) VehicleLoan
(VLoanid, Amount, Custid)
create table Customer(Custid number primary key,Custname varchar(20),phno number,DOB
varchar(20));
create table HomeLoan(HLoanid int primary key,Amount float,Custid number);
alter table HomeLoan add foreign key(Custid) references Customer(Custid);
create table Vehicle(Vloanid number primary key,Amount float,Custid int);
alter table Customer add pan number;
insert into Customer values(101,'Rajan',93837271,'2002-02-12',8472);
insert into Customer values(102,'kumar',38734832782,'2002-09-02',3473);
insert into Customer values(103,'Vikram',726281719,'1999-08-01',3573);
insert into Customer values(104,'Ragavan',7262823219,'1948-7-5',2573);
insert into Homeloan values(1223,100000,101);
insert into Homeloan values(3437,5000000,102);
insert into Vehicle values(3746,100000,103);
insert into vehicle values(2322,500000,104);
a) List the Custid of the customers who have both homeloan and vehicle loan.
a. select Custid from Customer where custid = (select Homeloan.custid from Homeloan inner
join Vehicle on Homeloan.custid=Vehicle.custid);
b) List the Custid of the customers who donot have any loan.
c) Create a view with customerid, Customer name and total loan amount (HomeLoan and
VehicleLoan)
d) Write a trigger which displays the Homeloan details whenever the values are inserted in
the respective table.
Table creation with Appropriate Constraints and Data Type (15)
Data Insertion (15)
Queries (a-c) (10 x 3 =30) marks
Trigger (d) (20) marks

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)
create table Product(Prodid number primary key,Price float,Stocks int);
create table Sales(Salesid number primary key,qut int);
insert into Sales values(736,20,302);
insert into Sales values(726,50,303);
insert into Sales values(716,10,304);
insert into Sales values(756,50,305);
b.select * from Sales;
a) Add a column reorder in Product table having value 50 for all products.
Page 4 of 12

a.alter table product add(reorder varchar(50));


b) Display the Sales Report.
b.select * from Sales;

c) Create an application for


i) User Login &
ii) checking the availability of a product in a stock.
Table creation with Appropriate Constraints and Data Type (15)
Data Insertion (15)
Queries (a-b) (20) marks
(c) 15 x 2 (30) marks

10. Create an application for student contacts management application. The application enables a faculty
user to login and search the details of a Student (Name, Address, Contact no, Email id, parent contact)
with his register number. Create necessary tables and Forms.
create table Student(Name varchar(20),Address varchar(20),Contackno int,email
varchar(20),parentcontact int);
insert into Student values('Siva','Srivi',483439829,'siva@xyz.com',82728271),
('Rayappan','Madras',384739282,'Rayappan@abc.com',845843873),
('Sundar','US',84989829,'Sundar@xyz.ccom',83748473),
('Veera','Eastcoast',83928282,'Veera@cnc.com',59838498);
Table creation , Appropriate Constraints and Data Type
(15)

Data Insertion (10)

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)
create table marks(regno int primary key,name varchar(20),dept varchar(20),subj1 int,sub2 int,sub3 int);
insert into marks values(02,'Aari','CSE',98,90,91),
(03,'Bhargav','CIVIL',89,68,90),
(04,'Bhavani','MECH',89,88,75),
(05,'CB','CIVIL',990,89,99);
desc marks;
select * from marks;
update marks set subj1=99 where regno=05;

select total from marks where total < (select max(total) from marks) order by total desc;

a) Add a column Total in student table and update the Total field with the sum of 3
subject Marks.
alter table marks add total int;
b) Find the second maximum total in the table.
update marks set total=marks.subj1+marks.sub2+marks.sub3 where regno;
select total from marks where total < (select max(total) from marks) order by total desc;
Page 5 of 12

c) Display the name of the student with maximum total.


select name from marks where regno = (select regno from marks having max(total));

d) Write a PL/SQL program to display the report sheet of the students using cursors.

Table creation with Appropriate Constraints and Data


Type (10)
Data Insertion (10)
Queries (a-c) (30) marks
(d) PL/SQL program (30)
15. Create the following tables with the mapping given below.
Employee (Empno, Ename, Job, MgrId, DoB, DoJ, Sal, Comm, Deptno)
Department (Dname, Deptno, Dloc)
create table employee3(Empno int primary key,Ename varchar(30),Job varchar(10),MgrId int,DOB date,
Doj date,sal float,Comm int,Deptno int);

create table Department(Dname varchar(20),Dept int primary key,Dloc varchar(20));


alter table employee3 add foreign key(Deptno) references DepartmenT(Dept);
insert into employee3 values(02,'Peter','AE',783,'2002-03-12','2024-06-12',650000,2,46),
(03,'Steve','AP',733,'2001-04-12','2023-06-12',750000,3,56),
(05,'Tony','Engineer',753,'1996-04-12','2020-06-12',100000,4,56);
select * from Department;

insert into department values('Marketing',46,'trichy'),


('Tech',56,'Chennai'),
('Marketing',45,'Bagalore');
(a) Display the Emp no, name, salary and experience of each employee ordered by
salary (highest to lowest)
select empno,ename,sal,comm from employee3 group by comm order by desc sal;

(b) List the names of the employee working for “Marketing” Department.
select Ename from employee3 where deptno is (select dept from Department
where Dname='Marketing');
select Ename from employee3 inner join Department on
employee3.deptno=Department.dept where Department.Dname='Marketing';
(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.
Page 6 of 12

Table creation with Appropriate Constraints and Data


Type (15)
Data Insertion (15)
Queries (a-c) (30) marks
(d) PL/SQL program (20)
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.

Table creation with Appropriate Constraints and Data


Type (10)
Data Insertion (10)
PL/SQL program (20)
Application Development
Database Design (10)
Front end (10)
Database connectivity and output (20)

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 .

Table creation with Appropriate Constraints and Data

Type (10)
Data Insertion (10)
PL/SQL program (20)
Application Development
Database Design (15)
Front end (10)
Database connectivity and output (15)
Page 7 of 12
Page 8 of 12
Page 9 of 12
Page 10 of 12
Page 11 of 12
Page 12 of 12

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)
create table User3(Userid int primary key,Name varchar(20),Dept varchar(20),Bookid int ,Accdate
date);
create table Book3(Bookid int primary key,Author varchar(20),Bookname varchar(20),Publication
varchar(20),price float);
alter table User3 add foreign key(Bookid) references Book3(Bookid);
insert into User3 values(02,'Arjun','Cse',4642,'2020-09-08'),
(03,'bala','civil',6352,'2022-09-06'),
(04,'Boopathy','Cse',5241,'2022-07-03'),
(05,'Cheran','Mech',7673,'2020-03-07'),
(06,'Ranjith','ECE',8732,'2022-11-07');
insert into Book3 values(4642,'James','PQT','Warnor-Bros',450),
(6352,'Arthor','DAA','VR Publication',800),
(5241,'Kamal','OS','Wiley',500),
(8732,'Anith','DBMS','Wiley',280),
(7673,'Amar','OS','VR Publication',500);
a) List the name of the user who had accessed the costliest book.
select name from User1 where Bookid =(select Bookid from Book1 having max(price));
b) List the userid and count of books accessed by the user. select
userid,count(Book3.Bookid) as Accesbook from User3 inner join Book3 on
User3.Bookid=Book3.Bookid group by Book3.Bookid;
c) List the books published by Wiley publisher
c.select Bookname from Book1 where Publication='Wiley';
d) Write a PL/SQL program to print the details of the book when Bookid is given as
input. Handle appropriate exceptions.

You might also like