Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

/ 00989

Sri Lanka Institute of Information Technology

8. Sc. Honours Degree


in
Information Technology
Final Examination

Year 3, Semester 1/2 (2023)

IT3020 -Database Systems

Duration: 2 Hours

June 2023

Instructions to Candidates:
• This paper is preceded by a 10-minute reading period. The supervisor will
indicate when answering may commence.
• This paper contains 4 questions. Answer Ail Questions.
• Use the booklets given to provide answers.
• Total marks for the paper will be 100.
• A mark for each question is mentioned in the paper.
• This paper contains 6 pages with the Cover Pager.
• Electronic devices capable of storing and retrieving text, including calculators and
mobile phones are not allowed.
-`,,
oog8\

Question I 25 marks

Consider the following object relational database schema for recording the information on the
doctors and patients in a hospital ward:

Object types:
Person_t (id: char(10), firstname: varchar(15), surname: varchar(15), bdate: date, phone:
char( 1 0)) not final
Doctor_t under person_t (regno: number, gdate: date, hiredate:date, specialty: varchar(15))
Admission_t (admdate: date, dischdate: date, doctor: ref doctor_t)
Admissions nt table of Admission t
Patient_t unEer person_t aid: nun6er, admissions: Admissions_nt)
Exam_t toatient: ref patient_t, datetime: date, doctor: ref doctor_t)

Tables:
Doctors of Doctor_t (regno primary key);
Patients of Patient_t ®id primary key)
nested table admissions store as admission_ntb;
Exams of Exam_ttoatient not null, datetime not null);

The attributes of Person_t are id, first name, surname, birth date and phone. Doctor t under
person_t has attributes registration number (regno), graduation date (gdate), hTre date
(hiredate) and specialty. Admission t has the attributes of admission date (admdate), discharge
date (dischdate) and admitting docior. Patient_t under person_t has the attributes patient id
®id), and admissions of nested table type. There is a tuple for each doctor in the Doctors
table, and a tuple for each patient in the Patients table. The Exams table records examinations
of patients by doctors and contains attributes of patient, date and time of examination, and the
examining doctor corresponding to the type, Exam t.

a) Write OR SQL statement to insert a new doctor in the above database systems. Use your
own sample data in OR SQL commands.
- (3 marks)

b) For all current patients in the ward, find the patient id, patient's first name, and the number
of examinations made by specialists during their current stay in the ward. For current
patients in the ward, the discharge date will be nun A doctor who is not a specialist will
have a null specialty value.
(6 marks)

c) Write Oracle SQL for implementing a member method on patient t that retuns the
number of previous admissions of a patient or return zero if there w=re none. Previous
admissions are indicated by discharge dates that are prior to the current date. The current
date and time is available in sysdate.

+ (8 marks)

Page 2 of 6
00989

d) Use the member method declared above to find the current patients who had more than 5
prior admissions. Display pid, surname, and the number of previous admissions. Current
patients can be identified by a dischdate of null.
(3 marks)

e) Critically analyse Oracle Object relational data model and XML data model.

(5 Marks)

Question 2 25 marks

a) Briefly explain three file organization techniques used in database systems to store and
manage data efficiently.
(5 marks)

b) Consider the following 8+ tree of order 2:

root

Illustrate the 8+ tree after inserting 18 and 30.


(5 marks)
C{

c) Construct an Extendible Hashed File for the following czge values. The hashing function
considers the last 2 digits of the binary representation.

(5 marks)

d) Consider a relation named pcrr/s with primary key, pz.d and 100,000 records stored in 10
records per block or page. If 1°/o of records are randomly accessed by pz.d values every
day, compare the costs in number of disk accesses between a hash index and a 8+ tree
index onpz.c7 values. Assume that both indexes use alternative 2.
(5 marks)

e) Provide four reasons to justify why most commercial databases support 8+ tree indexes.
(5 marks)

Page 3 of 6
oog8\

Question 3 25 marks

a) What is the justification for using I/0 costs as the main measure to compare different
algorithms for evaluating relational operators?
(2 marks)

b) Briefly explain why it is often advantageous to do selections before joins in a query plan.
How do early projections help during the query execution?
(3 marks)

c) Consider the following schema:


Employee (eno, enane, address, salary, pno)
Project ®no, pname, description, budget, head)

There are 10000 employee records on 100 pages and 1000 project records on 10 pages.
E7%p/o);ee and Pro/.ec/ relations have clustered 8+ tree indexes on Emp/o);ee<p#o> and
P7`o/.ec/<p72o> fields respectively. Assume equal sized fields for E77ep/o};ee and Pro/.ec/
relations. Also assume that the employee and project records are in sorted order because
of the existing clustered indexes. There are 20 buffer pages available.

i. Considerthe following query:


SELECT e.pno, AVG(e.salary)
FROM Employee e
GROUP BY e.pno

What additional indexes (if any) would you create to improve the performance of the
above query? Justify your answer.

(Hint: Find the cost of plans to justify your answer.)


( 10 marks)

ii. Considerthe following query:

SELECT e.*
FROM Employee e, Project p
WHERE e.pno = p.pno AND E|
p.budget > 25000000
ORDER BY e.pno

Assume that 5% of the tuples in Pro/.ec/ relation meets the selection condition. Estimate the
cost of the best plan possible, assuming that you can create index(es) of your choice.
( 1 0 marks)

Page 4 of 6
00989

Question 4 25 marks

a) Briefly explain the properties of a transaction.


(4 marks)

b) Consider the following scenario, which is a practical example of cascading aborts in the
context of a banking system with multiple concurrent transactions.

Transaction T1 : Transfer 500 from Account A to Account 8.


Transaction T2: Transfer 300 from Account 8 to Account C.
Transaction T3 : Transfer 200 from Account C to Account D.

Assume that all three transactions are executing concurrently. Initially, all account
balances are as follows:

Account A: I,000
Account 8: 800
Account C: 600
Account D: 400

T1: sO T2: 3cO

Batsz"# loco Ea-8sO Batimce sO Bakmc&- 2cO

Analyse this scenario and describe the effect of cascading abort if Tl transaction cancelled
due to a network failure or an unexpected error.
(7 marks)

c) Consider the following part of the transaction schedule.


T1 T2 T3 T4
S(A)
R(A)
S(C)
R(C)
X(C)
X(B)
W(B)
X(B)
X(D)
W(D)
X(D) -.;

X(A)

Page 5 of 6
ocg89`

Assume that Transaction Ti is higher priority than transaction Ti+I(i.e. transaction Ti has
higher priority than T2; T2 has higher priority than T3; and T3 has higher priority than T4).

i. Review the provided transaction schedule and analyse the reasons for the delay in
completing these transactions. Assume that the strict two-phase locking protocol
has been used to enable concurrency.
(3 marks)
ii. Draw a wait-For-Graph for the given schedule and check for deadlock.
(2 marks)
iii. Draw the schedule again considering deadlock prevention algorithm: Wound-wait
approach.
(4 marks)

d) Consider the following 8+ tree. Follow Simple Tree Locking Algorithm and specify when
and what lock ge_ts and releases to do the followings:

i.
EHHE HEEH
Search 58
(1'marks)
ii. Insert 30
(2 marks)
iii. Delete41

(2 marks)

- End of the Question Paper -

•r

Page 6 of 6

You might also like