IT3031-Database Systems and Data-Driven Application
IT3031-Database Systems and Data-Driven Application
Data Science
Final Examination
Year 3, Semester I (20 19)
Duration: 2 Hours
June 2019
Instructions to Candidates:
+ This paper is preceded by a I 0-minute reading period. The supervisor will
indicate when answering may commence.
+ Write answers in the booklet given.
+ The paper contains 4 questions. Answer All Questions.
+ Total marks for the paper is I 00.
+ The paper contains 6 pages with the Cover Page.
+ Electronic devices capable of storing and retrieving text, including calculators and
mobile phones are not allowed.
Question 1 (25 marks)
Consider the following XML document for the questions given below:
<?xml version="1.8" encoding="UTF-8"?>
<dept bldg = "181">
<employee id="135">
<name>Ramesh</name>
<phone>8714123123</phone>
<office>344</office>
<age>38</age>
</employee>
<employee id="137">
<name>Malith</name>
<phone>8776126126</phone>
<office>345</office>
<age>45</age>
</employee>
<employee id="138">
<name>Prabash</name>
<phone>8777123123</phone>
<office>345</office>
<age>41</age>
</employee>
</dept>
Note that the above XML document stored in department (id int emp xml} table created
in MS SQL Server and it contains only single record.
2. Write an XQuery (FLWR) expression to retrieve the name of the employee whose employee
id 137.
(3 marks)
Page 2 of 6
5. Write an expression to insert the following employee details after employee ID 135.
<employee id="136">
<name>Samanthi</name>
<phone>8714123222</phone>
<office>348</office>
<age>21</age>
</employee>
(5 marks)
6. Write an XQuery expression to extract data from employee xml document and create an
HTML table containing the names of all the employees along with their respective contact
numbers. Use the following HTML tags in your answer.
<table>
<tr>
<th>Name</th>
<th>Contact details</th>
</tr>
<tr>
<td>Ramesh</td>
<td>8714123123</td>
</tr>
<tr>
<td>Prabash</td>
<td>8777123123</td>
</tr>
</table>
(6 marks)
2. 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)
Page 3 of 6
6 Consider the B+ tree index below.
Bucket A
r-~:- 2=J27j_:_l_
Bucket D
Illustrate the hash index after inserting 55.
(5 marks)
4. List the possible conflicts that may arise with interleaving actions of transactions.
(3 marks)
Page 4 of 6
5. Consider the following part of the schedule.
T1 T2 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)
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).
The Emp table contains tuples of all employees, Proj table contains tuples of all projects and
Work table has tuples indicating employees assigned to projects. Suppose an important
query is to find the details of project assignments to employees of a given department using
an SQL statement of the form:
Page 5 of 6
Select e.eno, w.pno, w.hours
From emp e, work w
Where e.eno = w.eno AND e.dept = 'D3';
Assume that project assignments to employees in the Work table are uniformly distributed
among all the employees and across all the projects and the employees are uniformly
distributed across 200 departments. For convenience, we also assume that all fields are of
equal size in each relation. There are 20 buffer pages.
2 Suppose a selection on Emp (with dept= 'D3') followed by an indexed nested loop join is the
preferred method of executing the query. To speed up this query, you are allowed to create
an index on each relation. Assuming that index entries are stored in the form <key, rid>,
what type of indexes (hash/ B+ tree, clustered/unclustered) would you choose and on which
attributes? Give reasons for your choice.
(7 marks)
3 Estimate the number of page 1/0s for executing the query based on the indexes you have
chosen and the corresponding plan.
(7 marks)
4 Assume that we want to join two relations Emp and Proj on Emp.dept=Proj.dept conditions.
If there were no indexes on the two tables, what would be the cost of a sort merge join?
(8 marks)
Page 6 of 6