You are on page 1of 10

FINAL

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 Monday 7th June 2010 (2 hours)

BAHRAIN 15:00 BOTSWANA 14:00


GREECE 15:00 HONG KONG 18:30
KENYA 15:00 LONDON 13:00
MALAYSIA 18:30 MALTA 14:00
MALAWI 14:00 MAURITIUS 16:00
MYANMAR 16:30 RWANDA 14:00
SAUDI ARABIA 15:00 SINGAPORE 17:30
SRI LANKA 17:30 SOUTH AFRICA 14:00
SYRIA 15:00 TANZANIA 15:00
TRINIDAD 09:30 VIETNAM 18:30
ZAMBIA 14:00 BANGLADESH 18: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 OTHER ELECTRONIC DEVICES ARE NOT PERMITTED


FINAL

1.
Section A (Compulsory)

1.
(a) W
hat are the roles of the Database Administrator (DBA)?
[8 marks]

(b) State the first two of the four main phases of query processing and briefly describe
what should happen in each phase identified.
[8 marks]

(c) Consider the diagram in Figure 1 below which shows occurrences of the
WorksIn relationship connecting occurrences of the entity types Person,
Department and Location.
.
Person Department
WorksIn
P1
D1
P2
D2
P3
D3
P4

D4
L1

L2

L3

L4 Location
Figure 1

(i) State the number of occurrences of the WorksIn relationship.


[1 mark]

(ii) From the given occurrences diagram, list the departments that have
more than one employee working in it.
[1 mark]

(iii) From the given occurrences diagram, identify the degree of the
WorksIn relationship.
[1 mark]

(iv) Using the Chen or UML notation, draw an Entity Relationship


diagram showing the WorksIn relationship and the three entity types
Person, Department and Location. Include the cardinality and
participation constraints on your diagram. DO NOT show any
attributes on the diagram.
[5 marks]

COMP1302 Database Design and Implementation


Page 2 of 10
FINAL

(d) Th
e relational structure in Figure 2 below captures a snapshot of the database tables of
a small estate agent database. A branch must have a manager and may have many
staff working in it. A member of staff can work in one branch only.

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
SL21 John White Manager M 01/10/1945 30000 B005
SL41 Julie Lee Assistant F 13/06/1965 9000 B005
SG66 Ahmed Mansoor Manager M 19/08/2003 35000 B007

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

Figure 2—A snapshot of the database tables for a small estate agent database

(i) Provide the output when the SQL code below is run against the
database snapshot. [4 marks]

SELECT city, postcode


FROM Branch
WHERE branchNo NOT IN
(SELECT distinct branchNo FROM Staff);

(ii) Express the SQL code below using a sub-query. [4 marks]

SELECT staffNo, fname, lname, position


FROM Staff s, Branch B
WHERE s.branchNo = b.branchNo AND
city = 'London';

COMP1302 Database Design and Implementation


Page 3 of 10
FINAL

(e) O
nly FOUR of the following statements are true. Write down the numbers of the
FOUR statements you believe to be true. Only the FOUR first answers will count.
DO NOT COPY ANY of the statements to your answer book.
[8 marks]

(i) A relational view that is produced from two base tables chosen from a
fully normalised relational schema is always in 3NF.

(ii) Functional dependency concept is equally applicable to views as for


base tables.

(iii) Enhanced Entity Relationship Model resolves the problems of Chasm


and Fan traps that may exist in conventional Entity Relationship
Models.

(iv) A candidate key cannot hold a NULL value.

(v) Executing the same program several times will generate several
transactions.

(vi) Deadlocks are likely to occur in using Pessimistic Concurrency


compared with Optimistic Concurrency.

(vii) A multilevel, B+ index supports both sequential and direct access to the
rows of a table.

(viii) Classification is one of the methods used in data mining to search for
hidden knowledge.

(ix) In Data Warehousing, putting two Star schemas together in a data


warehouse gives a Snowflake schema.

(x) In Object Oriented DBMSs, object identifiers are used both by


application programs for referencing objects and for representing
relations between objects.

COMP1302 Database Design and Implementation


Page 4 of 10
FINAL

Section B (Answer and TWO questions)

2. The relational structure in Figure 3 below captures a snapshot of the database tables of
a Musical database. The stored information is about Artists and Music. One artist can
have one or many albums and an album can have one or many artists related to it. An
album can be a compilation of many artists. The Artist table consists of only the Artist
ID and the Artist Name (Full name). The Album table consists of the Album ID,
Album (or Single) name, the Genre ID (lookup to the Genre table), the Label ID
(lookup to the Label table) and the Album Release Date.
Part of the relational schema of the Music database is shown in Figure 4 on the
following page. The primary key for each table is underlined. The relationships
diagram for this relational schema is also presented below in Figure 5.

tblAlbum
lngAlbumID strAlbumName lngGenreID lngLabelID dteAlbumReleaseDate
2 Now That's What I Call Music! Vol. 52 6 1 22/07/2002
3 Heathen Chemistry 2 2 01/07/2002
4 Fever 1 3 01/10/2001
5 The Best Bands in the World...Ever 6 4 04/11/2002
6 Reloaded Vol.4 5 5 21/01/2002
7 The Joshua Tree 1 6 01/03/1987
9 The Eminem Show 7 7 27/05/2002
10 The Marshall Mathers LP 7 7 11/09/2000
11 Forget About Dre [CD Single] 7 7 29/05/2000

tblLabel tblArtist tblLINKArtist_Album


lngLabelID strLabelName lngArtistID strArtistName lngArtistID lngAlbumID
1 EMI 1 U2 1 6
2 Big Brother 2 Kylie Minogue 1 7
3 Parlophone 3 Oasis 2 2
4 Virgin TV 4 Moby 2 4
5 Universal Music TV 5 Stereophonics 3 3
6 Island 6 Eminem 3 5
7 Interscope 7 Dr Dre 4 2
4 5
5 2
tblGenre 5 6
lngGenreID strGenreDescription 6 9
1 POP 6 10
2 ROCK 6 11
3 PUNK 7 11
4 EASY LISTENING
5 COUNTRY
6 COMPILATION
7 RAP/HIP HOP
8 DANCE

Figure 3 —A snapshot of the database tables for the Music database


(not all the data are displayed)

COMP1302 Database Design and Implementation


Page 5 of 10
FINAL

tblGenre (lngGenreID, strGenreDescription);


tblAlbum (lngAlbumID, strAlbumName, lngGenreID, lngLabelID, dteAlbumReleaseDate);
tblArtist (lngArtistID, strArtistName);
tillable (lngLabelID, strLabelName);
tblLINKArtist_Album (lngArtistID, lngAlbumID);

Figure 4 — Part of the relational schema for the Music Database

Figure 5—A relationship diagram for part of the Music 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) The rock & roll band Oasis had a new manager just before June 2002. The
manager decided to delay the release of all new albums until the Christmas
season of that year (i.e. beginning of December 2002). However, the database
was not updated at the time. You have been asked to update the dates for all
albums released by that group during that period (i.e. between 1/6/2002 and
31/11/2002). [5 marks]

(ii) For each album that was produced by more than one artist, list the name of the
album and the total number of artists associated with it.
[5 marks]

(iii) Produce a list of artist names and the total number of Albums that each artist
produced before 2002. [5 marks]

COMP1302 Database Design and Implementation


Page 6 of 10
FINAL

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

Note: The function DatePart("yyyy", fieldname) filters the four-digit year of


the value of the referenced field.

(i) SELECT G.strGenreDescription as Genre, count(A.lngGenreID) as Total


FROM tblAlbum A, tblGenre G
Where DatePart("yyyy", A.dteAlbumReleaseDate) = 2002 And
A.lngGenreID =G.lngGenreID
Group by G.strGenreDescription; [3 marks]

(ii) SELECT Distinct strLabelName, strGenreDescription


FROM tblLabel, tblGenre, tblAlbum
Where tblGenre.lngGenreID = tblAlbum.lngGenreID and
tblLabel.lngLabelID = tblAlbum.lngLabelID
and DatePart("yyyy", dteAlbumReleaseDate) < 2001; [3 marks]

(iii) SELECT strArtistName as Name


FROM tblArtist , tblLINKArtist_Album
where tblArtist.lngArtistID = tblLINKArtist_Album.lngArtistID
group by strArtistName
having count(*) < > 2; [3 marks]

(iv) SELECT B.strAlbumName


FROM tblArtist A, tblLINKArtist_Album L, tblAlbum B
where A.lngArtistID = L.lngArtistID and
B.lngAlbumID = L.lngAlbumID
Group by L.lngAlbumID, B.strAlbumName
Having count(L.lngAlbumID) = 2 ; [3 marks]

(v) SELECT DatePart("yyyy", A.dteAlbumReleaseDate) as year,


A.strAlbumName
FROM tblAlbum A, tblAlbum B
WHERE DatePart("yyyy", A.dteAlbumReleaseDate) =
DatePart("yyyy", B.dteAlbumReleaseDate)
AND A.lngAlbumId <> B.lngAlbumId
Group by DatePart("yyyy", A.dteAlbumReleaseDate), A.strAlbumName
HAVING DatePart("yyyy", A.dteAlbumReleaseDate) < 2000;
[3 marks]

COMP1302 Database Design and Implementation


Page 7 of 10
FINAL

3.
(a) T
he relational schema below represents a simple family model where a record of a
person and his father and mother is stored. A person is allocated a unique social
security number (SSN), his/her full name (FName), Gender, Date of Birth (DoB),
and a unique identifier of his/her father and his//her mother. A person may have
children but must have a father and a mother.

FName Gender
SSN
DOB

1 Person 1 Mother_of
Father_of
N N

Map the above Relational Schema into one Relational table. Do not add additional
attributes to the list. Underline the primary key and identify any foreign keys by
drawing an arrow from each foreign key pointing to the referenced primary key. Do
not add any additional attributes.
[10 marks]

(b) Modify the diagram to present a marriage scenario. A person may marry one
person of the other opposite sex at one time. For each person a record of the marital
status must be maintained. These include Single, Married, Divorced, or a Widowed.
A widow is single person whose spouse has deceased. A person with a married
status cannot marry again until he/she gets a divorce. Historical records of previous
marriages or divorces must be maintained by recording the relevant date (e.g. one
can retrieve partners’ identities and date of previous marriages of any given
person). Reproduce the diagram above to include this scenario.
[10 marks]

(c) Map your diagram into a relational schema. Underline the primary key and
identify any foreign keys by drawing an arrow from each foreign key pointing to
the referenced primary key. Do not add any additional attributes.
[10 marks]

COMP1302 Database Design and Implementation


Page 8 of 10
FINAL

4)
4)
(a) Integrity is a feature of a DBMS. Consider the following scenario: An investment
company operates out of a single office in Hong Kong. Its business is based on
many years of high quality service, honesty, and reliability. The CEO (Chief
Executive Officer) is concerned that the firm has become too dependent on its
computer system. If some disaster should occur and the firm’s databases were lost,
its reputation for reliability would disappear overnight — along with many of its
customers in the highly competitive business.
Discuss what you think the firm should do to ensure database integrity.
[10 marks]

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


£500 from account ACC1 to account ACC2. At the same time, transaction B
processes every account record and adds interest payments by increasing each
balance by 100%. Initially, ACC1 has a balance of £2000 and ACC2 £100. The
following sequence of operations takes place:

Transaction A Transaction B
Read ACC1 record and lock
Reduce balance by 500
Write balance & Release lock
Read account ACC1 and lock
Update balance by 100%
Write ACC1 & Release lock
Read ACC2 record and lock
Update balance by 100%
Write balance & Release lock
Read account ACC2 and lock
Increase balance by 100%
Write ACC2 & Release lock

(i) What are the actual final values resulting from the above sequence
when transactions A and B are executed in an interleaved manner?
Show how you calculated your results.
[5 marks]

(ii) What should be the final balance value if the transactions were
performed serially? Show how you calculated your results.
[5 marks]

COMP1302 Database Design and Implementation


Page 9 of 10
FINAL

(c) Identify the type of problem in each of the two transaction schedules presented
below. Justify your answer.
(i) [5 marks]

(ii) [5 marks]

COMP1302 Database Design and Implementation


Page 10 of 10

You might also like