You are on page 1of 10

EXAMINATION PAPER: ACADEMIC SESSION 2006/2007

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 21ST May 2007

BAHRAIN – 15:00 MALTA – 15:00


GREECE – 15:00 SINGAPORE – 18:30
HONG KONG – 18:30 TRINIDAD – 09:30
LONDON – 13:00 UAE – 16:00
MALAYSIA – 18:30 ZAMBIA – 15:00

You MUST answer question 1.


Marks will be awarded for your best THREE answers to the remaining FIVE questions.
If you answer more than THREE questions, marks will ONLY be awarded for your
THREE best answers.

Each question is worth 25 marks.


CALCULATORS AND ELECTRONIC DEVICES ARE NOT PERMITTED
APPROVED

1. (a) Consider the diagram in Figure 1 below which shows occurrences of the
Registered-In & Assessed-In relationships along with the three entity
occurrences for Student, Course and Assessment. The following are few of the
business rules that are related to the shown diagram:
• A student must register in at least one course;
• A course can be taken by many students;
• Each course has two assessments (coursework and exam).
• The assessment marks for the coursework and exam are recorded for
every student for each course.

Reg-In C1
ASS1 A1C1
REG1 Cswk
S1
C2 ASS2 A2C1
REG2 Exm
S2
ASS3 A1C2
REG3 C3 Cswk
S3
ASS4 A2C2
REG4 Exm
Course C
ASS5 A1C3
Student S
REG5 Cswk
ASS6 A2C3
REG6 Exm
Assess-By

REG7 Assessment A

Figure 1

From the given occurrences diagram:

(i) State the number of occurrences of the Assess-By relationship.[1 mark]


(ii) Identify the degree of the Reg-In relationship. [1 mark]
(iii) Identify the cardinality of the Reg-In relationship. [1 mark]
(iv) Identify all students who are doing C3. [1 mark]
(v) Identify the courses that have less than four students in them. [1 mark]

(b) For the occurrence diagram in Figure 1 above, produce the Entity
Relationship Diagram. Identify the cardinalities and the participation
constraints for all relationships. Do not include any attributes on your
diagram.
[5 marks]

Database Design & Implementation


COMP1302
Page 2 of 10
APPROVED
Q1 Continued
(c) Referencing the model you produced in the previous section, you have been
asked to include marks for each assessment components for each course that a
student is registered in. You also have been asked to include for the
coursework assessment, the set-up date, submission date, expected number of
required hours, percentage weight. For the exam, however, we need to keep
information on the exam date, exact time, duration of the exam and the exam
rubric. REDRAW your diagram above to cater for these changes showing for
each entity, the candidate identifiers and any other attributes that resulted
from the additional information you got in this section.
[5 marks]

(d) The relational structure in Figure 2 below captures a snapshot of the


employee database table (EMP) for a small company. An employee may
manage other employees.
EMP
EMPNO EMPFNAME EMPSALARY DEPTNAME BOSSNO
1 Ali £75,000.00 Management
2 Ole £45,000.00 Sales 1
3 Joi £25,000.00 Sales 2
4 Clare £22,000.00 Marketing 2
5 Mohammed £38,000.00 Accounting 1
6 Khan £22,000.00 Accounting 5
7 Choi £43,000.00 Marketing 1
8 Sarah £56,000.00 Purchasing 7
9 Sophie £35,000.00 Personnel & PR 1
10 Sami £46,000.00 Purchasing 2
Figure 2

(i) Provide the output when the Structured Query Language (SQL) code
below is run against the database snapshot. [3 marks]

SELECT B.EMPNO AS MngrNo, B.EMPFNAME AS MngrF_Name,


Count(E.empno) AS No_Of_Supervisee
FROM EMP AS B, EMP AS E
WHERE E.bossno=B.empno
GROUP BY B.EMPNO, B.EMPFNAME
HAVING Count(E.empno)>1;

(ii) Express the following request in SQL. [2 marks]

For the Accounting and Sales departments, find the total salaries for their
employees.

Database Design & Implementation


COMP1302
Page 3 of 10
APPROVED
Q1 Continued

(e) Only FIVE of the following statements are true. Write down the numbers of the
FIVE statements you believe to be true. DO NOT COPY ANY of the
statements to your answer book. [5 marks]

(i) There is no analogy to grouping and aggregation functionalities in basic


relational calculus.

(ii) There are some queries that can be expressed in relational algebra or
relational calculus but not in SQL.

(iii) Query by Example can be used to perform calculations on the data in


tables.

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

(v) Granting privileges by a user who has created his/her database schema
objects (e.g. table, view, etc.) to another user is an example of granting
user privileges at a system level.

(vi) Database prototypes help users determine whether database performance


will be acceptable by the designers.

(vii) The client server information system architecture usually allocates


database processing to the server.

(viii) During database design, weak associations can always be eliminated.

(ix) The distinction between weak associations, part-of relationships and is-a
relationships is a semantic one and not an implementation one.

(x) A file can have at most one primary index, one clustering index, & can
have several secondary indexes.

Database Design & Implementation


COMP1302
Page 4 of 10
APPROVED

2. The relational structure in Figure 3 below (spread over two pages) captures a
snapshot of the database tables of Sunshine & Relaxation Ltd which is a small
company which operates a number of hotels along the Mediterranean coast.
The Database system has been developed a few years ago and was then installed at
each of the hotels, so they are operating completely independent from each other.
Each hotel has a small server which runs the hotel’s database and booking system
locally. Sunshine & Relaxation are now offering special deals where visitors can
spread their holiday stay over two hotels in the same or two different cities. For
example, a visitor can stay 2 nights at the original hotel in Quinta do Caracol hotel in
Tavira city and 5 nights in la Ferme d’Augustin hotel in Ramatuelle city under the
same booking. The original hotel permanently stores information on the original
booking (e.g. 2 nights Quinta do Caracol) and temporary stores information on the
destination booking (e.g. 5 nights in la Ferme d’Augustin), to be sent to the hotel at a
later stage. We assume that guests have the same requirements in both hotels.
Figure 4 shows the relationship diagram for the booking database. The primary key
in each table is underlined.
tblGuest
GuestID Surname FirstName DateOfBirth Gender
2014 Dixon Jim 12/01/1962 Male
2015 Dixon Elizabeth 15/05/1960 Female
2016 Smith David 12/12/1964 Male
2017 Ali Mohammed 01/07/1954 Male
2018 Ali Sukainah 10/03/1959 Female
2019 Patel Farook 01/01/1970 Male
2020 Hersay Jamila 23/07/1968 Female
2021 Lost Kamal 16/02/1999 Male
2022 Sodani Sahar 29/10/1970 Female
2023 Siddiqui Yosuf 01/01/1977 Male

tblOriginBooking
OrigHotBookID OriginHotel City RoomNo ArrivalDate DepartureDate
1001 Colón Barcelona 5 15/08/2007 18/08/2007
1003 Parador de Málaga Málaga 32 10/07/2006 12/07/2006
1004 Parador de Zafra Zafra 24/12/2007 02/01/2008
1005 Casa Três Palmeiras Praia do Vau 9 03/11/2007 05/11/2007
1006 Quinta do Caracol Tavira 21 15/02/2007 17/02/2007
1007 la Ferme d’Augustin Ramatuelle 6 12/02/2007 17/02/2007
1008 Parador de Almagro Almagro 12/05/2007 17/05/2007
1010 America Granada 12 02/05/2007 04/05/2007
1012 Casa Imperial Seville 3 23/11/2007 25/11/2007
1013 la Judería Seville 8 24/08/2007 30/08/2007
1015 Il Piccolo Golf Cala di Volpe 17 17/04/2007 20/04/2007
1016 Tonino Corda Padru 04/01/2008 10/01/2008
1017 Inglaterra Barcelona 2 23/11/2007 25/11/2007
1019 Colón Barcelona 5 19/08/2007 25/08/2007
1020 Colón Barcelona 5 04/04/2008 12/04/2008
1021 Quinta do Caracol Tavira 05/01/2008 12/01/2008

Figure 3—A snapshot of the database tables for Sunshine & Relaxation Ltd
(not all the data are displayed)

Database Design & Implementation


COMP1302
Page 5 of 10
APPROVED
Q2 Continued
tblBookingRequirements tblSpecialRequirements tblBookingGuest
BookingID RequirementsID ReqID Requirement BookingID GuestID
1001 6 1 Disability 1001 2014
1001 8 2 Wheelchair access 1001 2015
1003 5 3 Noise sensitive 1003 2016
1005 4 4 Non-feather bedding 1004 2016
1005 7 5 Non-smoking 1007 2017
1006 5 6 Travelling with Pet 1007 2018
1015 3 7 Special Diet 1006 2019
1017 4 8 Vegetarian 1008 2019
1017 7 1010 2019
1019 4 1012 2019
1019 7 1013 2020
1020 3 1016 2020
1021 4 1005 2021
1021 7 1019 2021
1017 2021
1021 2021
1015 2022
1020 2022

tblDestBooking
DestHotBookID DestinationHotel City RoomNo ArrivalDate DepartureDate
1001 Inglaterra Barcelona 7 18/08/2007 22/08/2007
1006 la Ferme d’Augustin Ramatuelle 13 17/02/2007 22/02/2007
1007 Parador de Almagro Almagro 8 17/02/2007 19/02/2207
1010 Parador de Guadalupe Granada 3 04/05/2007 08/05/2007
1013 Rey de Baeza Seville 12 31/08/2007 04/09/2007
1015 Parador de Guadalupe Guadalupe 5 21/04/2007 23/04/2007
1017 Claris Barcelona 4 27/11/2007 28/11/2007
Figure 3 Continued —A snapshot of the database tables for Sunshine & Relaxation
Ltd (not all the data are displayed)

Figure 4 —The Relationships diagram for Sunshine & Relaxation Ltd database

Database Design & Implementation


COMP1302
Page 6 of 10
APPROVED
Q2 Continued

(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) List the guest identification number, first and last names of the guest who
has most bookings. [6 marks]

(ii) List Guest number and Surname of all guests who made more than two
bookings in the same hotel. [4 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 marks each to 15 marks]

Note: the clause DateDiff ("yyyy", date1, date2) calculates the difference in
years between the first and the second date. DateDiff (“mm”, date1, date2)
gives the difference in months and DateDiff (“d”, date1, date2) gives the
difference in days.

(i) SELECT DISTINCT G.FirstName+" "+G.Surname as FullName


FROM tblBookingGuest AS BG, tblGuest AS G, tblOriginBooking AS OB
WHERE G.GuestID=BG.GuestID AND
BG.BookingID=OB.OrigHotBookID AND
OB.DepartureDate between #01/01/2008# AND #31/12/2008# AND
OB.OrigHotBookID IN
(SELECT distinct BookingID FROM tblBookingRequirements);

(ii) SELECT DISTINCT OB.OrigHotBookID, OB.OriginHotel,


DB.DestinationHotel, DB.City
FROM tblOriginBooking OB, tblDestBooking DB
WHERE EXISTS(SELECT tblDestBooking.DestHotBookID
FROM tblDestBooking
WHERE OB.OrigHotBookID=DB.DestHotBookID AND
OB.City=DB.City);

(iii) SELECT DISTINCT DateDiff ("yyyy", G.DateOfBirth, now()) As


GuestAge
FROM tblGuest G, tblOriginBooking OB, tblBookingGuest AS BG,
tblBookingRequirements BR, tblSpecialRequirements SR
WHERE G.GuestID = BG.GuestID AND
BG.BookingID = OB.OrigHotBookId AND
OB.OrigHotBookId = BR.BookingID AND
BR.RequirementsID = SR.ReqID AND
SR.Requirement ="Vegetarian"

Database Design & Implementation


COMP1302
Page 7 of 10
APPROVED
Q2 Continued
(iv) SELECT DISTINCT G.Surname, DateDiff("d", OB.DepartureDate,
DB.ArrivalDate) AS NoOfDays
FROM tblGuest AS G, tblOriginBooking AS OB, tblBookingGuest AS
BG, tblDestBooking AS DB
WHERE
G.GuestID=BG.GuestID AND
BG.BookingID=OB.OrigHotBookId AND
OB.OrigHotBookID=DB.DestHotBookID
GROUP BY G.Surname, DateDiff("d", OB.DepartureDate,
DB.ArrivalDate)
HAVING SUM (DateDiff("d", OB.DepartureDate, DB.ArrivalDate)) >=1;

(v) SELECT G.GuestID, G.FirstName+" "+ G.Surname AS FullName


FROM tblGuest AS G
WHERE G.GuestID NOT IN
(SELECT DISTINCT GuestID FROM tblbookingGuest);

3. Databases may be designed from three different approaches namely:


• DB design from existing data,
• DB design for a new information system, and
• DB design from redesigning an existing database.

Discuss the three approaches and identifies tools and techniques that might be used in
each approach. Provide example situations where each approach would be desirable.

[25 marks]

4. (a) Discuss the relationship between data warehousing and OLAP. [4 marks]

(b) Describe how star, snowflake, starflake and constellation schemas differ.
[6 marks]

(c) The star, snowflake, starflake and constellation schemas offer important
advantages in a data warehouse environment. Describe these advantages.
[15 marks]

Database Design & Implementation


COMP1302
Page 8 of 10
APPROVED

5. (a) The security of databases is of vital importance to the organization especially in


the case of sensitive or valuable information. List the computer based and non-
computer based controls that you will consider in order to ensure maximum
information security. Do not describe.
[7 marks]

(b) You land a high-paying database administrator job in the Greenwich


Corporation and your lucrative bonus depends on your ability to dramatically
improve the performance of their application. On taking a look at the database
schema and application, you determine the following information:

Their relational schema consists of a single table:


Employee (Id, Name, Age, Bursary, Level).
The functional dependency Age Æ Level holds over Employee.
No indices are built on the table.
The most common application update task, which occurs quite frequently, is to
give all employees a 10% salary raise (this is one of the reasons you chose
to join the company)
The most common application query task is to take “age” as an input from the
user, and issue an SQL query to select the names and salaries of
employees of the given age.

You are given two design goals. First, your performance tuning should not
negatively impact on the performance of the update operation. Second, you
should not change any of the SQL statements (both update and query) in the
application.

(i) Describe how you can exploit the physical data independence property of
relational databases to speed up the performance of their most common
query, while still meeting your design goals. You should clearly explain
how physical data independence is used by your solution.
[6 marks]

(ii) Show how you can exploit the logical data independence property of
relational databases to speed up the performance of their most common
query, while still meeting your design goals. You should clearly explain
how logical data independence is used in your solution.
[6 marks]

(iii) Describe how logical and physical data independence can be realized in a
three-level ANSI-SPARC database architecture. Your answer should
clearly show the levels in your architecture at which each of these
concepts is implemented. [6 marks]

Database Design & Implementation


COMP1302
Page 9 of 10
APPROVED

6. Concurrent transactions can create several problems when they are executed without
control.

The scenario in figure 5 below represents two transactions (T1 and T2) that
encounter one of these problems.

(a) Identify the type of the problem and the reason for it. [4 marks]

(b) Which transaction properties you think are violated as a result of this
execution? [4 marks]

(c) For each violation(s) suggest the required action and identify the DBMS
subsystem that is typically responsible to perform such an action.
[4 marks]

(d) Briefly explain how these actions are implemented in general terms.
[4 marks]

(e) Suggest a sample schedule for executing the transactions.


[4 marks]

(f) The recovery subsystem requires some data in order to perform the required
action. Where this data is usually stored and how it is used in the recovery
process?
[5 marks]

Time Transaction T1 Transaction T2

read_item(X);
X:=X-N;
write_item(X);
read_item(X);
X:=X+M;
write_item\(X);

read_item(Y);
T1 fails and aborts
Y:=Y+N;
write_item(Y);

Figure 5

Database Design & Implementation


COMP1302
Page 10 of 10

You might also like