You are on page 1of 6

FAT Lab Examination – DEC 2021

Programme : B.Tech Semester : Fall 2021

Course Database Management Systems Code :


: CSE2004
Title Lab

Faculty (s) : Dr.S.L.JAYALAKSHMI Slot :


L39+L40

Time : 3.50 PM To 5.30PM Max. Marks : 50

Marks Distribution

Mark split up

QUIZ 10 Marks

Table creation and insertion 10 Marrks

Sql query 15 marks

Pl SQL 15 marks

Total 50 Marks

Instructions:

 Name all the tables ending with last four digits of your Regno.E.g.emp1075,dept1075
 Upload a PDF document, with questions, tables created, Records of the tables and
SQL queries with answers, PL/SQL programs with the output.
 Insert a minimum of 5 Records for each table and No query must return an answer
“No rows found”
 Proper schema representation and list of attributes has to be assumed based on the
queries listed.
Questions
1)
a) Create the following tables with given attributes having appropriate data type
and specify the necessary primary and foreign key constraints:

ACTOR (Act_id, Act_Name, Act_Gender,City)

DIRECTOR (Dir_id, Dir_Name, Dir_Phone, City)

MOVIES (Mov_id, Mov_Title, Mov_Year, Mov_Lang, Dir_id)

MOVIE_CAST (Act_id, Mov_id, Role)

RATING (Mov_id, Rev_Stars)

Write the following queries in SQL

i. Find the title of movies and number of stars for each movie that has
at least two ratings and find the lowest number of stars that movie
received. Sort the result by movie ID. (4)
ii. Create a view to display the Movie details with Act_ name,
Dir_name, Movie_lang, and movie_title for the actor and director
who belongs to the same city.(3)
iii. Update rating of all movies directed by „Shankar‟ to rating value
10. (3)
iv. Update the view “Movie Details” to change movie language from
Tamil” to “Engish”. (2)
v. List out the actor names who has released their movies in the
current year.(3)

b) Create a PL/SQL program to find the movie names where one or more actors
acted in two or more movies. (15)

2)
a) 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, HAmount, Custid)
VehicleLoan (VLoanid, VAmount, Custid)
Write the following queries in SQL

i. List the id(cust id) of the customers who have homeloan but not
vehicle loan.(3)
ii. List the Customer details who is having vehicle loan amount
>10000.(3)
iii. Create a view with customer id, Customer name and total loan amount
(HomeLoan and Vehicle Loan) and display the no. of customers those
who are having less than 15000 as total loan amount. (3)
iv. Make a list of customers who holds average home loan amount greater
than 10000 and vehicle loan amount less than the average vehicle loan
amount of all the customers. (3)
v. Increase the vehicle loan by 0.45 times for all customers who were
born before 2005. (3)

b. Write a simple PL/SQL block to accept the HLoanid as „HL12345‟ from user
and print the loan amount and custID for that loanID.(15)

3)

a).Create Tables as follows by choosing appropriate data type and set the
necessary primary , foreign key constraints and add a constraint to salary
constraint such that it should be always >0.

Staff (STAFF_ID, FIRST_NAME,


LAST_NAME,NET_SALARY,JOINING_DATE, DEPARTMENT)

Increment(STAFF_ID, Increment_DATE, Increment_AMOUNT)

Job_description(STAFF_ID, STAFF_DESIGNATION, EFFECTIVE_FROM)

i) Write an SQL query to list the deptname with total staffs, if the count is >5 at
each dept and the name of the dept has letter „C‟.(3)
ii) Write an SQL query to fetch the no. of staffs working in each department in
the descending order.(3)

iiI) Write an SQL query to print details of all the Managers those who got more
than 5000 as increment(department_wise). (3)

iv) Write an SQL query to fetch the list of staffs with the same salary and
increment(3)

V) Write an SQL query to fetch the departments that have less than 10 people in
it. (3)

b). Write a PL/SQL procedure to delete the details of the STAFF_ id 101. (15)

4)

a) Create the following tables with given attributes having appropriate data type
and specify the necessary primary and foreign key constraints.

a.Books Table:

i. isbn – primary key

ii. title - unique

iii. price – not null

iv. qty – not null

b.Authors Table:

i. authorId – primary key

ii. email

i. Author_name

c.Book_Authors:

i. isbn – foreign key references books table


ii. authorId – foreign key references authors table

Write the following queries in SQL

i)Alter not null constraint in price attribute in books table and set the check
constraint so that value is greater than 0.0 (2)

ii)List the details of books with same price and same quantity(2)

iii)Create a view for displaying the list of the authors who published book in the
title of „Operating system‟ and „SQL‟ (4)

(iv)Display the book details that have exactly 6 characters in their names and
beginning with D,O and A letters.(3)

(v)Delete the book detail which has only one qty.(2)

(vi)List the ISBN numbers of the book with the price more than 1000.(2)

b) Write a PL/SQL code to retrieve the book_name, Author_name, and book


price from Book-author database by giving author-id as input by the user. (15)

5)

a).Create the following schemas with the constraints mapping given below.

Airport (Airport_id, AName, city)

Flight (FlightNo, Airport_id, DepTime, ArrTime, fare)

Booking (FlightNo, Pid, Airport_id fromdate,todate)

Passenger (Pid, PName, Address, TelNo,Gender)

Write the SQL query for the following:


i. Display the details of Airport_ID, Flight_no, Pname and their cities for
those travelled between august month and december month.(3)
ii. Count the number of passengers in each flight. (3 marks)
iii. Make a list in ascending order for the passengers who paid less than 3000
and travels to either „Delhi‟ or‟ Chennai‟. (3 marks).
iv. For each airport that has more than 3 flights, retrieve the airport ID and
number of its flights which are charging more than Rs.10000. (3)
v. Find the number of flights that is booked by all the passengers and
managed by Airport_ID „INT1234‟.(3 marks)
b) create a PL/SQL program to list the name of the passenger who has paid the
maximum fare.(15)

You might also like