Sie sind auf Seite 1von 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
GREECE
KENYA
MALAYSIA
MALAWI
MYANMAR
SAUDI ARABIA
SRI LANKA
SYRIA
TRINIDAD
ZAMBIA

15:00
15:00
15:00
18:30
14:00
16:30
15:00
17:30
15:00
09:30
14:00

BOTSWANA
HONG KONG
LONDON
MALTA
MAURITIUS
RWANDA
SINGAPORE
SOUTH AFRICA
TANZANIA
VIETNAM
BANGLADESH

14:00
18:30
13:00
14:00
16:00
14:00
17:30
14:00
15:00
18:30
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
SA9
SG14
SG37
SG5
SL21
SL41
SG66

fName
Mary
David
Ann
Susan
John
Julie
Ahmed

lName
Howe
Ford
Beech
Brand
White
Lee
Mansoor

Branch
branchNo
B002
B003
B004
B005
B007

position
Assistant
Supervisor
Assistant
Manager
Manager
Assistant
Manager

street
56 Cover Drive
163 Main Street
32 Manse Road
22 Deer Road
16 Argyll Street

sex
F
M
F
F
M
F
M

DOB
19/02/1970
24/03/1958
10/11/1960
03/06/1940
01/10/1945
13/06/1965
19/08/2003

city
London
Glasgow
Bristol
London
Aberdeen

salary
9000
18000
12000
24000
30000
9000
35000

branchNo
B007
B003
B003
B003
B005
B005
B007

postcode
NW10 6EU
G11 9QX
BS99 1NZ
SW1 4EH
AB2 3SU

Figure 2A 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.


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

[4 marks]

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
2
3
4
5
6
7
9
10
11

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

tblLabel

tblArtist

tblLINKArtist_Album

lngLabelID strLabelName
1
EMI
2
Big Brother
3
Parlophone
4
Virgin TV
5
Universal Music TV
6
Island
7
Interscope

lngArtistID strArtistName
1
U2
2
Kylie Minogue
3
Oasis
4
Moby
5
Stereophonics
6
Eminem
7
Dr Dre

lngArtistID lngAlbumID
1
6
1
7
2
2
2
4
3
3
3
5
4
2
4
5
5
2
5
6
6
9
6
10
6
11
7
11

tblGenre
lngGenreID strGenreDescription
1
POP
2
ROCK
3
PUNK
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 5A 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

Father_of

Person
N

Mother_of

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 firms 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)

COMP1302 Database Design and Implementation


Page 10 of 10

[5 marks]

Das könnte Ihnen auch gefallen