IT3020 - Database Systems3
IT3020 - Database Systems3
Information Technology
Final Examination
Year 3, Semester I
Duration: 2 Hours
June 2019
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 All 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 7 pages with the Cover Pager.
Question 1 (25 marks)
The Theatres table has attributes of theatre number (tno), name, city and phone. It contains
tuples for all theatres. Films table contain tuples for all films, and has the attributes film number
(filmno), title, language of the film, director's name (director), budget in dollars (budget), and
stars of the film. The stars nested table consists of the attributes name, gender (M=male and
F=female) and date of birth. The Showing table contains a tuple for each theatre and a film it
shows, along with the start date (startdate) and end date (enddate). The attribute types are
specified in the type descriptions above, as also are the primary keys and referential constraints
in the table schema.
(a) Write Oracle object SQL to insert an object to film table. Use appropriate sample data fit
into data types.
(4 marks)
(b) Display the names of female stars who have acted in films that are currently successful.
Assume that a successful current film has an average show period of 100 days or more at
each theatre where it is being screened now (current screening is indicated by enddate
value of null). Subtracting a date dl from another date d2 (where d1<d2) gives the duration
between them in days as a positive integer. Use sysdate for current date.
(6 marks)
(c) For each theatre, find the title of film(s) that played for the longest period (i.e. the longest
unbroken period). Display the theatre name, city and the title of the film. Subtracting a date
dl from another date d2 (where d1<d2) gives the duration between them in days as a
positive integer.
(6 marks)
(d) Write Oracle SQL for implementing a member method on theatre_t that returns the number
of films a given theatre is currently showing. The films currently being shown at a theatre
are indicated by an enddate of null in the Showing table. (Remember that each method
specification in the type body is a PL/SQL block and it can contain select statements on other
tables of the database.)
(9 marks)
Page 2 of 7
'I
/
;'
/ Question 2 (25 marks)
\][]
-:-_- ;- (e}..:. Consider the B+ tree index below.
~~~~JL~JLJLJflE]-~--[~~~r~~~
·· i: Illustrate the tree after inserting 12.
(3 marks)
. .- n; · illustrate the tree after deleting 22 from the original tree .
(2 marks)
(f)' Consider the Hash~inde-x below.
~·--=~LJ.
Bucket A
_I
oo ~J~ --------[ ~J 33
1 L_J
01 : ~
,-----.--;
Bucket B
~; m~••••i••i
11 . 23 ' 27
Bucket 0
31 :
:
Page3of7
(g) Consider the following schema:
SELECT S.sname
FROM Sailors S, Reserves R, Boats B ,
WHERE S.sid = R.sid AND R.bid = B.bid AND B.color ='red'
1!·l'fl "~-W--f_.t _,._il J~
i. Create the relational algebra expression for the query above. ·
T1 Tz T3 T4
S(A)
R(A)
X(B)
W(B)
S(B)
R(B)
S(D)
R(D)
X(A)
W(A)
S(C) ·'
R(C)
S(C)
R(C)
Page 4 of 7
Assume that Transaction T; is higher priority than transaction T;+l(i.e. transaction T1 has
higher priority than T2; T2 has higher priority than T3; and T3 has higher priority than T4).
Describe the steps involved in executing each of the following operations according to the
Simple Tree Locking algorithm, in terms of the order in which nodes are locked, unlocked,
read and written. Be specific about what type of locks are obtained and released.
i. Search 40.
(1 marks)
ii. Delete 9.
(2 marks)
iii. Insert 40.
(2 marks)
h) Consider the following scenario:
Database D
Page 5 of 7
Database 0 contains a relation R. Relation R contains 1000 pages. Assume that multiple
granularity locking scheme is used.
Describe the locks acquired when reading all pages in relation Rand modify about 5 pages,
which can be identified only after reading relation R.
(2 marks)
Consider the following XML document that contains information on a collection of books.
Note that the above XML document stored in Planes(xText XML) table created in MS SQL Server
and it contains an only single record.
Page 6 of 7
')
FROM planes
(4 marks)
b) Write an XQuery (FLWOR) expression to retrieve the models made before 1970.
Produce the following output.
<oldPlanes>
<make> Cessna </make>
<model> Centurian </model>
<make> Piper </make>
<model> Tripacer </model>
</oldPlanes>
(8 marks)
c) Write an XQuery expression to extract data from books XML document and create an HTML
table containing the model of all the planes along with their color. Use the following HTML
tags in your answer.
<table>
<tr>
<th>Model</th>
<th>Color</th>
</tr>
<tr>
<td> Tripacer </td>
<td> Blue <ltd>
</tr>
</table>
(8 marks)
Page 7 of 7