0% found this document useful (0 votes)
30 views7 pages

IT3020 - Database Systems3

Uploaded by

jathurshanm3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views7 pages

IT3020 - Database Systems3

Uploaded by

jathurshanm3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Sri Lanka Institute of Information Technology

B. Sc. Honours Degree


.
Ill

Information Technology
Final Examination
Year 3, Semester I

IT3020 -Database Systems

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)

Consider the following object relational schema for a Movie database:


Object types:
Theatre_t (tno:integer, name:string, city:string, phone:string)
Star_t (name: string, gender:char(l), birthdate:date)
Stars_nt table of Star_t
Film_t (fi/mno:integer, title:string, language:string, director:string, budget:float, stars stars_nt)
Show_t (film reffi/m_t, theatre reftheatre_t, startdate:date, enddate:date)
Tables:
Theatres of theatre_t (tno primary key)
Films of film_t (film no primary key) Nested table stars store as stars_ntb
Showing of show_t (film references films, theatre references theatres)

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.

Write Oracle Object SQL statements to answer following questions.

(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)

(a) Briefly explain the three main file organizations.


(3 marks)
(b) Consider a student relation containing records with student id, name, age and gpa. Assume
that the records are stored in a hash file where the hash function is based on the student's
age.
"Retrieving records with gpa of 3.0 is inefficient with the above file"
State whether the statement above is true or false with reasons.
(3 marks)
(c) Briefly explain two disadvantages that exist in static hashing.
(3 marks)
-(d) Explain the terms dense and sparse index.
(2 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

:: L -~--------.fi i "I " •


Bucket C

~; m~••••i••i
11 . 23 ' 27

Bucket 0
31 :
:

Illustrate the hash index after inserting 55.


(4 marks)

Page3of7
(g) Consider the following schema:

Sailors(sid, sname, rating, age)


Boats(bid, bname, color)
Reserves(sid, bid, day)
. .-- .~
Consider the following query:

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. ·

} . ,·,,.. ·•. (2 marks)


,'
ii. Draw the graphical representation of the relational algebra expression
(3 marks)

Question 3 (30 marks)

a) List and briefly explain the properties of a transaction.


(4 marks) .,

b) Briefly explain the following terms in database transactions:


Serial Schedule and Serializable Schedule
(2 marks)
c) Briefly explain the rules in Strict 2 Phase Locking Protocol.
> )

d) List the possible conflicts to arise with interleaving actions of transactions.


. " ..
(2 marks)
e) Consider the following part of the schedule.

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).

i. How does a deadlock occur?


(2 marks)
ii. How does the DBMS detect a deadlock?
(2 marks)
iii. How the DBMS resolves deadlock (after it has occurred).
(1 mark)
iv. Draw a wait-for graph for the schedule given above to detect the deadlock.
(2 marks)
v. Draw the schedule again considering deadlock prevention algorithm:
Wait-Die approach
(3 marks)
f) Briefly explain what the "phantom problem" is.
(2 marks)
g) Consider the tree shown below.

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)

Question 4 (20 marks)

Consider the following XML document that contains information on a collection of books.

'<?xml version="1.0" encoding="UTF-8"?>


<planes>
<plane>
<year> 1977 </year>
<make> Cessna </make>
<model> Skyhawk </model>
<Color> Light blue and white </color>
</plane>
<plane>
<year> 1975 </year>
<make> Piper </make>
<model> Apache </model>
<color> White </color>
</plane>
<plane>
<year> 1960 </year>
<make> Cessna </make>
<model> Centurian </model>
<color> Yellow and white </color>
</plane>
<plane>
<year> 1956 </year>
<make> Piper </make>
<model> Tripacer </model>
<color> Blue </color>
</plane>
</planes>')

Note that the above XML document stored in Planes(xText XML) table created in MS SQL Server
and it contains an only single record.

a) What would be the output of the following XQuery expression?

SELECT xText.query (' let $planes :=/planes/plane


return <results>
{
for $x in $planes
where $x/year >= 1970
order by ($x/year)[1]
return ($x/makeJ $x/modelJ$x/year
}
</results>

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)

- End of the Question Paper -

Page 7 of 7

You might also like