Sie sind auf Seite 1von 7

UNIVERSITY OF MAURITIUS

FACULTY OF ENGINEERING

FIRST SEMESTER EXAMINATIONS

November/December 2009

PROGRAMME BSc (Hons) Computer Science


BSc (Hons) Information Systems
MODULE NAME Database Systems 1
DATE Monday MODULE CODE CSE 1005(1)
30 November 2009
TIME 13.30 – 15.30 hrs DURATION 2 Hours
NO. OF QUESTIONS 5 NO. OF QUESTIONS 4
SET TO BE ATTEMPTED

INSTRUCTIONS TO CANDIDATES

There are 2 Sections in this paper: Section A and Section B.

Section A consists of 3 compulsory questions.

Section B consists of 2 questions. Answer only ONE (1) question from Section B.
DATABASE SYSTEMS 1 – CSE 1005(1)

SECTION A (COMPULSORY)

Answer All Questions in this Section

Question 1 [25 Marks]

(a) (i) Describe, using appropriate examples, the constraint called Referential Integrity.
[4 marks]
(ii) Explain what is meant by Data Independence.
[3 marks]

(b) Harolds Rentals Case Study

Harolds Rentals is a company which rents out vehicles (cars and vans). It has various
outlets (garages/offices). Each outlet has a number, address, phone number, fax
number and a manager who supervises the operation of the garage and offices at each
site.

Each site is allocated a stock of vehicles for hire. However, individual vehicles may
be moved between outlets, as required. Only the current location for each vehicle is
stored. The registration number uniquely identifies each vehicle for hire and is used
when hiring a vehicle to a client.

Clients may hire vehicles for various periods of time (minimum 1 day to maximum 1
year). Each individual hire agreement between a client and the company is uniquely
identified using a hire number. Information stored on the vehicles for hire include: the
vehicle registration number, model, make, engine size, capacity, current mileage, daily
hire rate, and the current location (outlet) of each vehicle.

The data stored on a hire agreement includes the hire number, the client’s number,
name , address and phone number, date the client started the hire period , date the
client wishes to terminate the hire period, the vehicle registration number, model and
make, the mileage before and after the hire period. After each hire a member of staff
checks the vehicle and notes any fault(s). Fault report information on each vehicle is
stored, which records the name of the member of staff responsible for the check, date
checked, whether fault(s) where found (yes or no), the vehicle registration number,
model, make and the current mileage.

…/cont’d next page

Page 1 of 6
DATABASE SYSTEMS 1 – CSE 1005(1)

Question 1(b) (continued)

The company has two types of clients: personal and business. The data stored on
personal clients includes the client number, name (first and last name), home address,
phone number, date of birth and driving licence number. The data stored on business
clients includes the client number, name of business, type of business, address,
telephone and fax numbers. The client number uniquely identifies each client and the
information stored relates to all clients who have hired in the past and those currently
hiring a vehicle.

Information is stored on the staff based at various outlets including: staff number,
name (first and last name), home address, home phone number, date of birth (DOB),
sex, National Insurance Number (NIN), date joined the company, job title and salary.
Each staff member is associated with a single outlet but may be moved to an
alternative outlet as required, although only the current location for each member of
staff is stored.

Draw an E-R Diagram for Harolds Company. Illustrate all entities, attributes,
relationships, cardinalities and other constraints.
[18 marks]

Question 2 [25 Marks]

The following relations form part of a relational database for a hotel.

Customers(CustId, Name, Address, Nationality, Phone, Email)


Rooms(RoomNo, Type, Floor, Price)
Booking(CustId, Room, DateFrom, DateTo, Status)

Note:
• The Primary Key of each relation is underlined
• 'CustId' in 'Booking' relation is a foreign key referencing to 'CustId' in 'Customers'
relation
• 'Room' in 'Booking' relation is a foreign key referencing to 'RoomNo' in 'Rooms'
relation
• The 'Price' attribute in 'Rooms' relation is the price per night for the room
• 'Type' in 'Rooms' relation can have values 'Single', 'Double' or 'Triple'
• 'Status' in 'Booking' relation can have values 'Confirmed', 'Reserved', 'Cancelled' or
'Completed'

(a) Write expressions in Relational Algebra to retrieve each of the following:

(i) The room numbers and prices of rooms of type 'Double'. [2 marks]

(ii) The names and nationality of customers whose bookings have been
'Cancelled'. [3 marks]

…/cont’d next page

Page 2 of 6
DATABASE SYSTEMS 1 – CSE 1005(1)

Question 2 (a) (continued)

(iii) The number of customers who have booked rooms which are of type 'Triple'.
[3 marks]

(iv) The name of customers who have booked all single rooms of the hotel.
[4 marks]

(b) Write expressions in SQL for each of the following:

(i) The type of room booked by customer ID 'C002' from 1st February 2008 to 5th
February 2008.
[3 marks]

(ii) Change the status of all bookings to 'Completed' where 'DateTo' is before the
current date.
[3 marks]

(iii) For each room type, find the total number of bookings which have been
'Confirmed'.
[3 marks]

(iv) Delete from the booking table the records for customers who have more than 2
'Cancelled' bookings.
[4 marks]

Page 3 of 6
DATABASE SYSTEMS 1 – CSE 1005(1)

Question 3 [25 Marks]

(a) Examine Table 1 shown below. The table lists customer/car hire data. Each customer
may hire cars from various outlets throughout Glasgow. A car is registered at a
particular outlet and can be hired out to a customer on a given date.

Table 1

(i) Describe the concept of functional dependency.


[2 marks]

(ii) Identify the functional dependencies represented by the data shown in the
Table 1. State any assumptions you make about the data (if necessary).
[3 marks]

(iii) Table 1 is susceptible to update anomalies. Provide examples of how such


anomalies could occur on this table.
[2 marks]

(iv) Using the functional dependencies identified in part (ii) above, describe and
illustrate the process of normalization by converting the table to Third Normal
Form (3NF) relations.
[10 marks]

(b) A database system is partitioned into modules that deal with each of the
responsibilities of the system and is broadly divided into storage manager and query
processor components. Describe the roles of the storage manager and the query
processor.
[8 marks]

Page 4 of 6
DATABASE SYSTEMS 1 – CSE 1005(1)

SECTION B

Answer ONLY ONE (1) question in this Section.

Question 4 [25 Marks]

Consider the following relations for a relational database for a library:

Books(BookId: Integer, Title: String, Author: String, YearPublished: Integer)


Borrowers(LibCardNo: Integer, Name: String, Address: String)
Loans(BookId: Integer, LibCardNo: Integer, BorrowDate: Date, DueDate: Date)

Note: Primary Keys are underlined.

(a) Express the following queries in Tuple Relational Calculus:

(i) Find the names of borrowers and the id of books they have borrowed.
[2 marks]
(ii) Find the title of books which have been borrowed in the year 2009.
[3 marks]
(iii) Find the names of borrowers living in Port-Louis who have never borrowed
any book from the library.
[3 marks]
(iv) Find the authors of books borrowed by 'Ed Williams' on 1st June 2008.
[3 marks]
(v) Find the names of borrowers who have borrowed at least two books on the
same date.
[4 marks]

(b) The database for the library is being designed and your help in being seeked for the
following:

Write a function, func, in PL/pgSQL for the following:


▪ The function takes as parameter the id of a book
▪ If the book is published before the year 2000, then the function returns
the title and author of the book.
▪ Otherwise, the function returns the names and addresses of the person
who borrowed the book on 1st January 2009.
[10 marks]

Page 5 of 6
DATABASE SYSTEMS 1 – CSE 1005(1)

Question 5 [25 Marks]

(a) Using appropriate examples, describe the ACID properties supported by good
Database Management Systems.
[10 marks]

A transaction is a logical unit of database processing that includes one or more access
operations. An application program may contain several transactions separated by the Begin
and End transaction boundaries.

(b) Explain the purpose of a System Log in Transaction Recovery.


[3 marks]

(c) Examine the execution of the two transactions T1 (A = A + B) and T2 (A = A * 50) as


follows:

T1: T2:

read_item(A)
read_item(B)
A := A + B
Time
read_item(A)
A := A * 50

write_item(A)

write_item(A)

(i) Name the type of problem that will arise if transactions T1 and T2 are
executed as shown?
[2 marks]

(ii) Explain the problem which arises in part (i).


[4 marks]

(iii) What is the correct value of A if both transactions were executed one after the
other and what is the wrong value of A if the transactions are executed as
shown? The original values of A and B before the transactions started were 5
and 10 respectively.
[6 marks]

END OF QUESTION PAPER


/kp

Page 6 of 6

Das könnte Ihnen auch gefallen