CSIT2040 - Database Systems
CSIT2040 - Database Systems
Final Examination
Year 2, Semester 1 (2022)
Duration: 2 Hours
November 2022
Instructions to Candidates:
oosee\
a) Convert the following EER model into the relational model. Indicate the primary keys and the
foreign keys of the resulted relations clearly. (16 marks)
b) What is the best option for mapping the ISA hierarchy in the diagram? Justify your answer.
(4 marks)
NIC
00C;$3
Consider a relation R (A, 8, C, D, E, F) with the following set of functional dependencies over R:
a) Find all the keys in relation R using attribute closure method. (4 marks)
b) Consider the following block of code written in Java Language. What is the type of statement in
which `s ' is an object of? How is it different from other types of statements? (2 marks)
do(
System. out . println ( "enter name : " ) ,.
String name=br . readLine ( ) ,.
System. out .println ( "enter salary: " ) ;
float salary=Float .parseFloat (br. readLine ( ) ) ;
s . setstring ( 1, name ) ,.
s . setFloat (2 , salary) ,.
int i=ps . executeupdate ( ) ;
c) Briefly explain the difference between full back ups and differential backups. (3 marks)
e) Consider the following requirements of a university which contains several programs having
modules related to database management systems.
A senior system administrator holds the responsibility of creating and maintaining databases
required for the modules. Under the senior system administrator a junior administrator carries
out the duties of creating logins and handling requests such as changing passwords. Module
leaders have all permissions within the database allocated to the module. Students on the other
\.
OOS03 \
hand are only capable of executing DDL or DML statements inside the database of the module.
They are not allowed to execute any procedures or triggers.
Consider the following schema of a database designed to track fuel issuance by a fuel provider.
Fillingstation (licenseNo: int, location : varchar(50), provider: varchar(30))
Vehicle (vRegNo : char(6), ownerNIC: char(10), fuelType : char(15), vehicleType:
char ( 30 ) )
Owner (NIC: char(10), name : varchar(25), age : int, gender: char(1), phone:
char ( 10 ) )
Filledln (vRegNo: char(6), licenseNo: int, amount : int, filledDate: datetime)
Quota (vehicleType: varchar(30), quota: int)
The Fillingstation table consists of license number (/I.ce775eIVo), /occz/I.o# of filling stations and the
name of the provz.c7er such as `IOC' and `Cepetco' . Vehicle table consists of registration number of
the vehicle (vJzegIVo), NIC of the owner (ow#erjwc), fuel type of the vehicle such as `Petrol' and
`Diesel' "2zeJr){pe) , type of vehicle such as `car','van' and `motor cycle' (vefoz.c/er)pe).Owner table
consists ofJVIC, #cz77ce, age, ge7cc7cr and pfrone number of each vehicle owner. Filledln table consists
of the registration number of the vehicle which had fuel pumped (vjzegIVo), license number of the
filling station at which the fuel is pumped (/I.ce77seIVo), the cz7%o##/ of fuel pumped in liters and date
and time at which the fuel is pumped 0?/JeczDczJe). The Quota table consists of type of vehicle such
as `car' and `van'(vefrz.c/er}pe) and g24oro of fuel given for a`week with respect to each type.
/ iijiG`j;-i-jt`j
//
a) Write SQL queries to answer following questions.
i. Display the registration number and type of all vehicles which has pumped fuel in from
fllling stations located at `Kunmegala' on 20th July 2022 (4 marks)
ii. Find the registration number of vehicle and NIC of the car owners which has not pumped in
fuel in August 2022 (6 marks)
Note : MONTH and YEAR function returns the month number and year given a date in SQL
server
iii. Find the NIC and name of vehicle owners who had got more than 1001iters of `Diesel'
pumped in to vehicles he owns within any month ofa year. (7 marks)
Note : MONTH and YEAR function returns the mohih number and year given a date in SQL
server
b) Create a functiori which accept vehicle registration number and calculate the remaining fuel
amount from the quota available for the vehicle for the current week considering the type of
vehicle and available quote as specified in Quota table. (12 marks)
Note: T~SQL function DATEPART(week,<date>) returns week's number within the year Of the
specified date.
c) Create a trigger to prevent vehicles from pumping fuel than the remaining quota of fuel for the
vehicle. (11 marks)