ER ExamRevision Exercises

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

Computing A2

Entity Relationship Exercises

1. The data requirements for a booking system are defined as follows:

An agency arranges bookings of live bands for a number of clubs. Each band is
registered with the agency and has its name (unique) recorded, together with the
number of musicians, the type of music played and hiring fee. Each band is managed
by a manager. A manager may manage several bands. Each manager is assigned an
identification number and managers have their name, address and telephone number
recorded. Each club is assigned an identification number and clubs have their name,
address and telephone number recorded.

The agency records details of each booking made between a band and a club for a
give date. A band will never have more than one booking on any particular date.

(a) In database modelling, what is:


(i) an attribute

It is a property that is stored for a particular entity.

(ii) a relationship

A link between two entities, so how an entity relates to another entity.

(b) Four entities for the booking system are Manager, Club, Band & Booking
(i) Suggest an identifier, with justification, for each of the entities
Manager, Club and Band.

For a band, you could use its name, because a band will never have
the same name as another band. For a manger, they each have an
identification number which is unique so this could be used. A club
also have an identification number so this could be used since its
unique to that club.

(ii) Describe 4 relationships involving the entities Manager, Club, Band


and Booking that can be inferred from the given data requirements.

One Manager manages many band, and one band is managed by one
manager. So its a one to many relationship.
One Club hires many bands, and one band plays in many clubs, so its
a many to many relationship.
One band may have many bookings, but one booking only exists for
one band so its a many to one relationship.
One club can have many bookings but one booking only refers to one
club so its a many to one relationship.

Kevin Lucas Page 1 4/25/2017


Computing A2
Entity Relationship Exercises

(c) A relational database is to be used. Describe tables for the following entities
underlining the primary key in each case:
(i) Manager

Identification Number, Name, address, Telephone Number

(ii) Band

Name, Number of musicians, type of music, hiring fee.

(iii) Booking

Club Id, Band Name, Date

Its really easy, just use some normal intuition as well as awareness of rules and
techniques for determining relationships to answer questions. Half the answers are in the
question, the other half you determine using knowledge and intuition.

2. The data requirements for a league of cross-country running clubs are defined as
follows:

The league consists of a number of participating clubs whose runners race against
each other in a series of races held throughout the season. The league secretary is
responsible for recording data about clubs, races, race entries, race results and club
league points.

Each race has a race identification number, date, start time, distance covered and
venue recorded. Runners from different clubs compete in each race. Each club has its
name (unique) and the name, address and telephone number of its results secretary
recorded.

On receipt of a race entry form from a club, the league secretary assigns each listed
runner a competitor identification number in the range one to one hundred and their
name and club name are recorded. This competitor identification number applies to
that particular race only. A competitors race time and position are recorded after each
race. The points a club scores for each race are computed from the positions of its
runners and recorded.

(a) 4 entities for the league are Club, Race, ClubRacePoints and RaceCompetitor.
Draw an entitity relationship diagram which shows four relationships involving
the entities Club, Race, ClubRacePoints and RaceCompetitor that can be inferred
from the given data requirements.
(b) A relational database is to be used. Using the following format
Tablename(attribute1,attribute2,attribute3, etc)

Kevin Lucas Page 2 4/25/2017


Computing A2
Entity Relationship Exercises

Describe tables, stating all the attributes, for the following entities underlining the
primary key in each case. These are the only tables that are used.

(i) Race
(ii) Club
(iii) RaceCompetitor
(iv) ClubRacePoints

3. A hospital stores details of its wards, patients and their medical condition in a database
in a way that will allow information about these details to be extracted.

The data requirements are defined as follows.

Each patient is assigned a patient number (unique), surname, forename, address,


date of
birth and gender.

Each ward has a number of beds.

Each ward is assigned a ward name (unique), name of the nurse in charge and the

number of beds it possesses.

Each medical condition that the hospital can treat is recorded.

Each medical condition is assigned a medical condition number (unique), name


and the
recommended standard treatment.

Each patient may suffer from one or more medical conditions.

A particular medical condition may be attributed to more than one patient.

The medical conditions of each patient are recorded.

Each ward has zero or more patients.

A patient can be assigned to only one ward at any one time.

Each ward may have patients with different medical conditions.

Kevin Lucas Page 3 4/25/2017


Computing A2
Entity Relationship Exercises

Four entities for the hospital database are

Ward, Patient, MedicalCondition, PatientMedicalCondition

(a) Using the partially complete entity relationship diagram shown in Figure 4, as an
aid, show the degree of three more relationships which exist between the given
entities.

Kevin Lucas Page 4 4/25/2017


Computing A2
Entity Relationship Exercises

b) Using the following format

TableName(PrimaryKey, Non-keyAttribute1, Non-keyAttribute2, etc)

describe tables, stating all attributes, for the following entities underlining the
primary key in each case.

(i)Ward ..........................................................................................................................

(ii)Patient ......................................................................................................................

...............................................................................................................................

(iii)MedicalCondition ...................................................................................................

...................................................................................................................................

(iv) PatientMedicalCondition .........................................................................................

.....................................................................................................................................

(c) Using the SQL commands SELECT, FROM, WHERE, write an SQL statement to

query the database tables for the forename, surname and medical condition number
of
all patients in Victoria ward.

Kevin Lucas Page 5 4/25/2017

You might also like