sc10 PDF
sc10 PDF
MAY 2017
INSTRUCTIONS TO CANDIDATES
Section A consists of two questions. Answer All questions from this Section.
Section B consists of three questions. Answer All questions from this Section.
SECTION A
(a) Give one advantage and one disadvantage of using views in a database
management system.
[4 marks]
(c) Allied Products Ltd is a manufacturing company that keeps a list of employees and
jobs that are scheduled for each day. All employees have an employee number,
name, address and date hired and are classified into only three main categories:
Managers, Engineers and Workers. Managers take care of managerial issues and
supervise other employees and their monthly car allowances are recorded. Each
Employee is supervised by only one Manager. Engineers are highly qualified
employees and their degree qualifications are stored. Workers perform jobs that
require specialized technical skills and each Worker may have many technical
skills, which are recorded.
Each job has a job code, a description and a job type of high, moderate and low
level of complexity. Every day, management gets a list of jobs required to be done
and a list of employees who are available. A job is then assigned to the employee
who has the required level of skills to perform the job on a given date, which is
recorded.
A database management system is required that will make easier the process of
assigning employees to jobs.
(d) Consider the relation RECIPE given in the following table, which is in un-normalized
form (0NF). Biscuit products are made from several ingredients. Suppliers supply
the various ingredients and are identified by supplier codes. Ingredients are
identified by ingredient code and products are identified by product codes. Several
ingredients are used and mixed in the right proportion to make the products.
(Question 1 continued)
Normalize the table data to 3NF, showing all the intermediate normal forms, relations and
functional dependencies. Clearly specify any assumptions made.
[8 marks]
2
DATABASE DESIGN AND IMPLEMENTATION– CSE2021Y(3)
(Question 2 continued)
(a) Express the following queries in Relational Algebra (RA).
(i) Find the id of all staff who work for the department number 'D001'.
[2 marks]
(ii) For each department number, find the number of students and the average
marks scored. [3 marks]
(iii) Find the surnames and first names of all staff who work in the 'Mechanical'
department as well as the ID of students they have supervised. The names
of staff who have not done any supervision should also be included.
[4 marks]
(ii) Find the minimum project mark for each year. [2 marks]
(iii) Find the surnames and first names of all students who have supervisors with
surname ‘Smith’ [3 marks]
(iv) Find the first names and surnames of heads of departments who have not
supervised any project.
[4 marks]
(c) Write a trigger which archives the data of the 'student' table whenever a row is
deleted. The schema of the archive table is as follows:
Note that the field 'studentName' will store the first name and surname of the
student.
When a row is deleted from the 'student' table, a corresponding row is inserted in
the 'student-deleted-log' table. Assume that the archive table already exists (there is
no need to create the table).
[5 marks]
3
DATABASE DESIGN AND IMPLEMENTATION– CSE2021Y(3)
SECTION B
(a) Give one advantage and one disadvantage of hash file organization. [4 marks]
(b) Extendible hashing is used with the initial hash function h(x) = x mod 8 and a
bucket or block size of 3 to create a hash file on a relation with the following search
keys:
7, 14, 21, 23, 32, 44, 49, 55, 62, 67, 74, 76
(i) Show the final hash structure after inserting the keys in the given order.
[8 marks]
(ii) Show the steps and how the directory and/or data structure changes when
the key 14 is deleted.
[4 marks]
(c) The B+ tree is one example of a dynamic multilevel index, where data pointers are
stored only on the leaf nodes. The diagram below shows the structure of a B+ tree
after a number of countries have been inserted, using alphabetic ordering.
Show how the tree will shrink when ‘Japan’ is deleted and what the final tree will
look like. [3 marks]
4
DATABASE DESIGN AND IMPLEMENTATION– CSE2021Y(3)
Consider the following transactions, T1 and T2, which are waiting to be processed in a
DBMS:
T1 T2
read(A); read(A);
read(B); read(C);
If A= B then A:=A+100; A:=A+C;
write(A); write(A);
read(D);
D:=C*D;
write(D);
(a) Show a possible interleaving of T1 and T2 which may result in the Lost Update
problem.
[4 marks]
(b) The Lost Update problem can be avoided by using Two-Phase Locking (2PL).
Show the new interleaving of the two transactions chosen in part(a) above, but now
with lock and unlock instructions following 2PL. Assume that locks are acquired only
when they are needed and released as soon as possible.
[5 marks]
(c) Using basic 2PL may sometimes result in a deadlock situation. Name and briefly
describe another type of 2PL which prevents deadlock situations.
[3 marks]
5
DATABASE DESIGN AND IMPLEMENTATION– CSE2021Y(3)
(a) Give two advantages and two disadvantages of Distributed Database Systems.
[4 marks]
(c) The following table forms part of the schema for the database of a departmental
store:
The following are the three most frequently issued queries on the table:
q1 q2 q3
SELECT desc SELECT SUM(p.price) SELECT category,
FROM product FROM product p, sales s COUNT(*)
WHERE category = WHERE p.pid = s.pid FROM product
'foodstuff' AND s.supplierId = 3; WHERE price > 100
GROUP BY category
The database is distributed across 3 sites, S1, S2 and S3. The query access
frequencies at each site are shown below:
S1 S2 S3
q1 5 15 10
q2 0 20 5
q3 10 0 5
Assuming that the table product has to be vertically fragmented into two
fragments,
(i) Construct the Attribute Usage Matrix (Q). You can refer to the attribute
names in the product table as A1, A2, A3 and A4 respectively. [2 marks]
(iii) The Clustered Affinity Matrix (CA) was derived using the Bond Energy
Algorithm and the attributes were ordered as follows: A2, A3, A4, A1. Use
Split Quality measure to find two vertical fragments of the product table.
[6 marks]