4-Mid Term Exam-06-07-2023
4-Mid Term Exam-06-07-2023
Database Systems
Mid-Term Exam
Slot: L5+L6
Question 1)
Consider the following relational schemas
Do the following
1. Create the above tables with composite primary on Passenger table and primary key on Train table.
Enforce the foreign keys on fields of ‘Reserved_for’ table.
2. See that ‘status’ field value should be any one of these ‘cf’ , ’ncf’, and ‘c’. Also see that ‘source’ and
‘destination’ fields should never be empty. Ensure that the date of journey should be not more than 30
days from date of reservation.
3. Add at least 6 records to each table as per the requirements of queries given as below.
Mandatory: Display the structure and content of each table for each change and store it in your file to
be uploaded. It carries 5 marks-
Answer the following queries in SQL and obtain required output (Output for each query be there in
your file and it carries half of the marks allotted to the query)
4. List tickets numbers along with train names that travels from ‘Bangalore’ to ‘Chennai’ on journey
dates between 13-November-2015 and 15-November-2015.
5. Display date of journey field values in the format ‘ddth of month yyyy’ by adding one day to it.
6. Get the total number of tickets reserved on each date of journey.
7. List the ticket numbers whose amount is more than the amount of every ticket on 13-November-
2015. (Sub Query)
8. Create a virtual table to display ticket numbers along with train numbers and train names on a
particular date of journey those travel from ‘Bangalore’ to ‘Tirupati’
-----------------------------------------------------End of Question1 --------------------------------------------------------------
Question 2)
Schema’s
Actor( aname: varchar2(20); role: varchar2(15); sex: char; amount :number(6); city:
varchar2(10))
Performs(aname: varchar2(20); title: varchar2(20))
Skit(title: varchar2(20); theme: varchar2(15); duration: number(3); rating:varchar2(3))
Do the following
1. Create the above tables with primary keys on appropriate fields. Enforce the foreign keys on fields of
‘Performs’ table.
2. Put a check constraint to see that rating of the skit should be any one of these A, A+, and
A++. Also see that the fields ‘role’ and ‘amount’ should be unique and not empty respectively.
Include ‘street’ column in the’Actor’ table of string data type.
3. Add at least 6 records to each table as per the requirements of the queries given below
Mandatory: Display the structure and content of each table for each change and store it in your file to
be uploaded. It carries 5 marks-
Answer the following queries in SQL and obtain required output (Output for each query be there in
your file and it carries half of the marks allotted to the query)
4. Change the city to ‘Chennai’ of an actor whose name start with ‘J’ and acted in the skit with
title ends with ‘n’.
5. Display number of male actors acted and their total remuneration skit wise.
6. Retrieve names of actors who perform in more than or equal to 2 skits.
7. List skit names in which female artists acted is more than or equal to male artists acted. (Sub
Query)
8. Create a virtual table that shows skit names with rating A+ and in which actors have been paid an
amount less than or equal to Rs.25000.
Schema’s
Do the following
1. Create the above tables with primary on appropriate fields. Enforce the foreign keys on the
fields of ‘Sings’ table.
2. Ensure that duration of each lyric should be not less than 5mins and not more than 7 mins.
Also ensure that field ‘singer_name’ should not be null. Eliminate ‘street’ field.
3. Add at least 6 records to each table as per the requirements of queries given below
Mandatory: Display the structure and content of each table for each change and store it in your file to
be uploaded. It carries 5 marks-
Answer the following queries in SQL and obtain required output (Output for each query be there in
your file and it carries half of the marks allotted to the query)
4. Display lyricid sung by each singer and then get total number of lyrics sung by each singer.
5. Retrieve maximum, minimum and average duration of songs for each movie.
6. Display date of recording of the song by adding one month to each one of them.
7. Retrieve the lyric whose duration is more than the duration of any other lyric in the movie
‘Khiladi’. (Sub Query)
8. Create a virtual table that displays singer names in capitals, movie title in smaller letters and the
length of movie titles.
Schema’s
Note: ‘start_date’ stands for start date of tutorial classes, ‘designation’ to be either ‘assistant
professor’, ‘professor’ or ‘senior professor’.
Do the following
1. Create the above tables with primary keys on appropriate fields. Enforce the foreign keys on fields of
‘Conducts’ table.
2. Ensure that fields ‘school’ and ‘t_fee’ should not be empty. Also see that duration of any tutorial
should be not more than 4 hours per session. Eliminate ‘place’ field.
3. Add at least 6 records to each table as per the requirements of queries given as below
Mandatory: Display the structure and content of each table for each change and store it in your file to
be uploaded. It carries 5 marks-
Answer the following queries in SQL and obtain required output (Output for each query be there in
your file and it carries half of the marks allotted to the query)
4. Obtain tutorial details conducted by tutors whose designation has got ‘professor’ as a substring.
5. List out the first 3 characters and last 3 characters of tutorial names whose’ duration’ is less than 3
hours.
6. Get the school names whose total number of tutorials conducted is more than or equal to 2.
7. Display tutorial name whose fee is less than the tutorial fee of any other tutorials. (Sub Query)
8. Create a virtual tableto get the tutorial names along with tutor names those conducted by schools
‘scse’ and ‘site’.
---------------------------------------------------------End of set 7------------------------------------------------------------------
Question 8)
Schema’s
Note: ‘doj’ stands for date of joining. Sample empid is ‘e001’ and sample pid is ‘p001’.
Do the following
1. Create the above tables with primary keys. Enforce foreign keys on the fields of ‘Works_On’ tab
2. Change the data type of field ‘plocation’ to accommodate variable size values in it, change the name
of the field ‘incentive’ to ‘perk’, and also see that employee id and project id should start with letter ‘e’
and ‘p’ respectively.
3. Insert at least 6 records in each table as per requirements of queries given below
Mandatory: Display the structure and content of each table for each change and store it in your file to
be uploaded. It carries 5 marks
Answer the following queries in SQL and obtain required output (Output for each query be there in
your file and it carries half of the marks allotted to the query)
4. Show project names in capitals and their locations as first letter in capital.
5. Display project name and employee name for projects either with budget not less than 3 lakhs or
located at ‘Chennai’
6. Retrieve number of employees works on each project and number of projects each employee works
on.
7. Get the project names whose budgets are the same as the budget of the project located at
‘Hyderabad’. (Sub Query)
8. Create a virtual table that displays locations where more than 2 projects are conducted.
Schema’s
Note: ‘dol’ stands for ‘start date of loan’ by the customer. Sample ‘cid’ are 100,101 and so on. Sampe
Loan no are 10000,10001 and soon. Loan type may be ‘Vehicle loan’, ‘Personal Loan’, ‘Housing Loan’ and
so on.
Do the following
1. Create the above tables with primary key on appropriate fields. Enforce the foreign key on the fields
of ‘Takes’ table.
2. See that customer names should be unique. Ensure that ‘birthdate’ of each customer should be 5
years earlier than current sysdate. Add field ‘branch_name’ to ‘Loan’ table.
3. Add at least 5 records to each table as per the requirements of queries given below
Mandatory: Display the structure and content of each table for each change and store it in your file to
be uploaded. It carries 5 marks
Answer the following queries in SQL and obtain required output (Output for each query be there in
your file and it carries half of the marks allotted to the query)
4. Get total number customer name whose loan amount more than Rs.30000.
5. Display loan details of customers whose age is not less than 35 years.
6. Retrieve the minimum, maximum and average loan amount of all loans sanctioned by each branch till
to date.
7. Display loan amounts those are more than every loan amount of loans given by ‘Katpadi’ branch of
the bank. (Sub Query)
8. Create a virtual table to display customer details that have taken loan at ‘Katpadi’ branch.
Schema’s
Note: tourist_id should be 1000,1001 and so on. tour_id should be t001, t002 and so on.
amount should be 1000.50, 1324.50 and so on
Do the following
1. Create the above tables with primary on appropriate fields. Enforce the foreign key on the
fields of ‘Travels_on’ table.
2. Put a check constraint to see that each tour id should start with letter ‘t’ and tour type be
either 1-day, 1-week or 2- week. Also ensure that ‘dob’ and ‘address’ fields are non empty.
3. Populate each table with at least 5 records as per the requirements of given queries
Mandatory: Display the structure and content of each table for each change and store it in your file to
be uploaded. It carries 5 marks
Answer the following queries in SQL and obtain required output (Output for each query be there in
your file and it carries half of the marks allotted to the query)
4. Show the tour details in ascending order of tour name and descending order of agent.
5. Display least and highest tour package amount offered by each travel agent.
6. List tourist names along with their tour names and package amount, whose age is equal to 25
years.
7. Display tour names whose package amount is less than the package amount of every tour
offered ‘Bharat Agency’ (Sub Query)
8. Create a virtual table to display tourist names who are on tour with id ‘t001’ and having
‘chennai’ as substring in their address.
------------------------------------------------------------End of set13--------------------------------------------------
-
Question 14)
Schema’s