You are on page 1of 9

EXAMINATION PAPER: ACADEMIC SESSION 2009/2010

Campus Maritime Greenwich

School Computing and Mathematical Sciences

Department Information System and Multimedia

Level Three

TITLE OF PAPER Database Design & Implementation

COURSE CODE COMP1302

Date and Time Thursday 3rd Dec 2009 (2 hours)

BAHRAIN 15:00 BOTSWANA 15:00


GREECE 15:00 HONG KONG 18:30
KENYA 16:00 LONDON 13:00
MALAYSIA 18:30 MALTA 14:00
MALAWI 14:00 MAURITIUS 18:00
MYANMAR 15:30 RWANDA 14:00
SAUDI ARABIA 16:00 SINGAPORE 17:30
SRI LANKA 18:30 SOUTH AFRICA 15:00
SYRIA 14:00 TANZANIA 16:00
TRINIDAD 09:30 UAE 17:00
ZAMBIA 15:00 BANGLADESH 18:30
VIETNAM 17:30

You MUST answer question 1 which is worth 40 marks

Answer TWO questions from the remaining THREE questions, questions 2 to 4 which are
worth 30 marks each. If you answer all THREE questions from questions 2 to 4, marks
will ONLY be awarded for your TWO best answers.

CALCULATORS AND ELECTRONIC DEVICES ARE NOT PERMITTED


FINAL

SECTION A – COMPULSORY

1. (a) Explain why an instance of a relation (i.e. a snapshot of a table) cannot be used
to prove that an attribute, or a combination of attributes, is a candidate key.
[8 marks]

(b) A recruitment establishment stores information about interviews by job


applicants to various companies. The diagram below is part of a conceptual
schema of the establishment. It states that for each job applicant, we need to
store the name and the postal address. We also record the name, phone number,
address and the social security number of the person in the company who is
responsible for the interview. Suppose that some interviews result in job offers,
while others do not.
(i) Explain why the Entity Relationship Schema below is incorrect for this
application.
[3 marks]
(ii) Correct and redraw the Entity Relationship Diagram for the schema
below according to the Extended Entity Relationship model.
[5 marks]

Postal Date Name Phone


Address Candidate Name EmpSSN
Address

Job_Applicant Company
Interview
1 1

1
Job_Offer

(c) (i) Explain how the view mechanism can be used to improve security in
database systems.
[4 marks]
(ii) Is the Entity Integrity rule applicable to views? Explain your answer by
giving an example.
[4 marks]

QUESTION 1 IS CONTINUED ON PAGE 3

Database Design & Implementation


COMP1302
Page 2 of 9
FINAL

QUESTION 1 CONTINUED FROM PAGE 2

(d) Give the equivalent English interpretation for the SQL query below, and
provide the output when the code is run against the snapshot of the employee
table (Emp) given below.
[8 marks]

SELECT DISTINCT E.FIRSTNAME, M.FIRSTNAME


FROM EMPCMS AS M, EMPCMS AS E
WHERE (M.EMPNO = E.MNGRNO AND E.SPECIALTY="ANALYSIS & DESIGN")
OR (M.EMPNO = E.MNGRNO ANDE.SPECIALTY="DATABASE SYSTEM");

EmpNo FirstName MngrNo Specialty


Emp
1 Ala 5 Database System
2 Yasser 7 Analysis & Design
3 Richard 5 Embedded Sys
4 Brian 5 Game Development
5 Miltos 8 Distributed Sys
6 Bob 8 System Software
7 Phil 8 Computing Ethics
8 Liz Object Orientation
9 Jason 23 Technical support
10 Liam 23 Technical support
11 Elaine 7 Analysis & Design
12 Gill 5 Programming
… … … …

QUESTION 1 IS CONTINUED ON PAGE 4

Database Design & Implementation


COMP1302
Page 3 of 9
FINAL

QUESTION 1 CONTINUED FROM PAGE 3

(e) Only FOUR of the following statements are true. Write down in your answer
booklet the numbers of the FOUR statements that you believe to be true.
ONLY THE FIRST FOUR NUMBERS WRITTEN WILL BE MARKED.
DO NOT COPY any of the statements to your answer booklet.
[8 marks]

(i) Deadlocks are unlikely to occur in using Optimistic Concurrency


compared with Pessimistic Concurrency.

(ii) If all concurrent transactions access objects in the same order, deadlocks
are less likely to occur.

(iii) Minimizing deadlocks can increase transaction throughput.

(iv) All 3rd Normal Form relations that are based on a single attribute primary
key are in Boyce-Codd Normal Form.

(v) The clustering attribute is not sequentially ordered in the index file.

(vi) Within an Enhanced ERD, a disjoint constraint determines whether or not


two or more subclasses can contain the same entity instance.

(vii) The Recovery Manager ensures isolation by making sure that all actions
of committed transactions survive system crashes and media failures.

(viii) In the out-of-place recovery technique, a shadow page refers to the newly
created page rather than the original data page.

(ix) Insertion and Deletion of a key value in a B-tree must not violate the
condition of M/2 +2 ≤ K ≤ M+2 where K is the number of Keys per
node and M is the order of the tree.

(x) Typical multi attributes search & scan performance is better on de-
normalized data because fewer tables are involved than in normalized
data.

Database Design & Implementation


COMP1302
Page 4 of 9
FINAL

SECTION B – Answer any TWO questions.

2. The relational structure in Figure 1 below captures a snapshot of the database tables
of a small database for an estate agent (real estate agency). A branch must have a
manager and many staff working in it. A member of staff can at most work in one
branch. A property can be viewed by many clients and a client can view many
properties. The primary key for each table is underlined. The relationships diagram
for this schema is shown in Figure 2 below.

Figure 1 — A snapshot of the database tables for the Estate Agent database (not all the data
is displayed)

PropertyForRent
propertyNo street city postcode type rooms rent ownerNo staffNo branchNo
PA14 16 Holhead Aberdeen AB7 5SU House 6 650 CO46 SA9 B007
PG16 5 Novar Drive Glasgow G12 9AX Flat 4 450 CO93 SG14 B003
PG21 18 Dale Road Glasgow G12 House 5 600 CO87 SG37 B003
PG36 2 Manor Road Glasgow G32 4QX Flat 3 375 CO93 SG37 B003
PG4 6 Lawrence Street Glasgow G11 9QX Flat 3 350 CO40 B003
PG97 Muir Drive Aberdeen SA9
PL94 6 Argyll Street London NW2 Flat 4 400 CO87 SL41 B005

Viewing Client
clientNo propertyNo viewDate comment clientNo fName lName telNo preType maxRent
CR56 PA14 24-May-01 too small CR56 Aline Stewart 0141-848-1825 Flat 350
CR56 PG36 28-Apr-01 CR62 Mary Tregar 01224-196720 Flat 600
CR56 PG4 26-May-01 CR74 Mike Ritchie 01475-392178 House 750
CR62 PA14 14-May-01 no dining room CR76 John Kay 0207-774-5632 Flat 425
CR76 PG4 20-Apr-01 too remote

Staff
staffNo fName lName position sex DOB salary branchNo
SA9 Mary Howe Assistant F 19/02/1970 9000 B007
SG14 David Ford Supervisor M 24/03/1958 18000 B003
SG37 Ann Beech Assistant F 10/11/1960 12000 B003
SG5 Susan Brand Manager F 03/06/1940 24000 B003
SG66 Ahmed Mansoor Manager M 19/08/2003 35000 B007
SL21 John White Manager M 01/10/1945 30000 B005
SL41 Julie Lee Assistant F 13/06/1965 9000 B005

Branch
branchNo street city postcode
B002 56 Cover Drive London NW10 6EU
B003 163 Main Street Glasgow G11 9QX
B004 32 Manse Road Bristol BS99 1NZ
B005 22 Deer Road London SW1 4EH
B007 16 Argyll Street Aberdeen AB2 3SU
Database Design & Implementation
COMP1302
Page 5 of 9
FINAL

Figure 2 — The relationships diagram for the Estate Agent database

(a) A set of applications has been planned against the database. You have been
asked to express the following requests in SQL. Referential integrity (cascade,
delete & update) is maintained automatically by the system.

(i) Increase the salaries of all female staff who are based in Glasgow branch by
3%.
[5 marks]

(ii) List staffno, fname, 1name and position for all staff who work in a London
branch office.
[5 marks]

(iii) Produce a list of all clients (full name and telephone number) who viewed
properties with 5 or more bedrooms.
[5 marks]

QUESTION 2 IS CONTINUED ON PAGE 7

Database Design & Implementation


COMP1302
Page 6 of 9
FINAL

QUESTION 2 CONTINUED FROM PAGE 6

(b) Another set of applications has been already coded in SQL. For each of the
given SQL code statements below produce the output using the data from the
above tables. Present your answer in a table format using column headers as
they appear in the query. Ignore any data modification that might have resulted
from executing the SQL statements that you have produced in section (a)
above.

(i) SELECT C.FName+" "+C.lname AS FullNAme, count(v.propertyNo) AS


NoOfViewedProperties
FROM Client AS C, PropertyForRent AS P, Viewing AS V
WHERE c.clientNo=V.clientNo and p.propertyNo=v.PropertyNo
GROUP BY C.Fname, C.lName
HAVING Count(*)>1;
[3 marks]

(ii) SELECT COUNT(S.staffNo) AS count,


SUM(salary) AS sum
FROM Staff S, Branch B
WHERE S.position = 'Manager' and
B.branchNo= S.branchNo and
b.city in ( 'London' , 'Glasgow') ;
[3 marks]

(iii) SELECT SELECT staffNo, fName, lName


FROM Staff
WHERE salary > ALL
(SELECT salary FROM Staff WHERE branchNo In
(Select branchNo from branch where city like 'London'));
[3 marks]

(iv) SELECT b.branchno, b.city, p.propertyNo, p.city


FROM Branch b left JOIN PropertyForRent p ON b.City = p.City
where b.city not in ( 'Glasgow', 'London');
[3 marks]

(v) SELECT m.fname+" "+m.lname as Fullname


from staff as m, staff as e
where e.fname ='Mary' and e.lname='Howe' and
e.staffno <> m.staffno and e.branchno = m.branchno and
m.position = 'Manager';
[3 marks]

Database Design & Implementation


COMP1302
Page 7 of 9
FINAL

3. (a) Advanced database applications require analytical tools that go beyond the
primitives found in the basic Entity Relationship Model. The Enhanced Entity
Relationship Model (i.e. EERM), and the Class Diagram used in the Object–
Oriented paradigm (i.e. OM) are two examples that cater for these new
application requirements.
Compare the two modelling tools, EERM vs. OM, in terms of their primitives
and advantages of one over the other.
[20 marks]

(b) In a Database system within a banking application, transaction A is transferring


£1000 from account ACC1 to account ACC2. At the same time, transaction B
is processing every account record and adding interest payments by increasing
each balance by 1.5%. Initially, ACC1 has a balance of £4000 and ACC2
£5000. The following sequence of operations takes place:

Transaction A Transaction B
Read ACC1 record and lock
Reduce balance by 1000
Write balance
Release lock
Read account ACC1 and lock
Update balance by 1.5%
Write ACC1 and release lock
Read account ACC2 and lock
Update balance by 1.5%
Write ACC2 and release lock
Read ACC2 record and lock
Increase balance by 1000
Write balance
Release lock

(i) What are the final values in ACC 1 and ACC 2 after the above
sequence of operations in transactions A and B have been executed in
an interleaved manner?
[3 marks]

(ii) What should be the final values in ACC 1 and ACC 2 if the
transactions were performed serially? [3 marks]

(iii) Comment on the results for sections (i) and (ii) above identifying any
problem encountered and how this problem can be avoided (if
possible)? [4 marks]

Database Design & Implementation


COMP1302
Page 8 of 9
FINAL

4. (a) Dimensional modelling offers important advantages within a Data


Warehousing environment. List five of these advantages and explain how each
advantage may impact on the Data Warehousing environment. Use examples to
illustrate your answer.
[20 marks]

(b) The two relations below represent a portion of a distributed relational schema
for a library system. The primary keys are underlined.
Branch (branchId, branchName, branchAddress)
Copy (accessionNo, ISBN, purchasePrice, branchNo)
Assume that the Copy table is horizontally fragmented by branchNo. Each
branch stores the fragment containing just those rows relating to the copies
stocked at that branch. There is no replication of Copy or fragments of Copy.
There is an average of 10,000 copies at each of 50 branches. The Copy
fragments are indexed by ISBN. The Branch table is replicated at every site.

Assume that staff at the Bexley branch want to find which of the other
branches stock copies of a book with a given ISBN.

There are several query plans that could be used to execute the above query.
For simplicity consider the two query plans below:

Query plan 1:
Transmit the Copy fragments from the other 49 branches to Bexley.
Search each fragment for a row with the given ISBN (on average
500 rows need to be searched for each fragment).
For each fragment with a matching row, use branchNo to find the
name and address of the branch from the Branch replica at Bexley.

Query plan 2:
Transmit the ISBN to each of the other 49 branches.
At each branch use the index on the Copy fragment to find whether
there is a copy at that branch; if so transmit the branchNo back to
Bexley.
Use the branchNo to find the name and address of the branch from
the Branch replica at Bexley.

(i) List the most important factors that you need to consider in distributed
query optimization.
[5 marks]

(ii) Study the two query plans above and pick the one that you think is
more efficient for the given scenario, and justify your answer.
[5 marks]

Database Design & Implementation


COMP1302
Page 9 of 9

You might also like