Professional Documents
Culture Documents
Level Three
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
(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]
(i) Provide the output when the Structured Query Language (SQL) code
below is run against the database snapshot. [3 marks]
For the Accounting and Sales departments, find the total salaries for their
employees.
(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]
(ii) There are some queries that can be expressed in relational algebra or
relational calculus but not in SQL.
(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.
(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.
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)
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
(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.
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]
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]
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]
(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]
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