Professional Documents
Culture Documents
Level Three
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.
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]
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]
(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]
(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]
(ii) If all concurrent transactions access objects in the same order, deadlocks
are less likely to occur.
(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.
(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.
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
(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]
(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.
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]
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]
(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]