0% found this document useful (0 votes)
17 views27 pages

Fundamentals of Databases Questions 2016-2023

The document outlines a relational database system used by a network of zoos to manage animal information for breeding programs, detailing the structure of various relations such as Zoo, AnimalLocation, Animal, and Match. It also includes questions related to database normalization, SQL queries, and design considerations for a sports center and an estate agency. Additionally, it discusses the use of CRUD and REST principles in a web application context, as well as the storage and identification of products in a warehouse.

Uploaded by

Tazim Padiyath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views27 pages

Fundamentals of Databases Questions 2016-2023

The document outlines a relational database system used by a network of zoos to manage animal information for breeding programs, detailing the structure of various relations such as Zoo, AnimalLocation, Animal, and Match. It also includes questions related to database normalization, SQL queries, and design considerations for a sports center and an estate agency. Additionally, it discusses the use of CRUD and REST principles in a web application context, as well as the storage and identification of products in a warehouse.

Uploaded by

Tazim Padiyath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Q1.

A network of zoos uses a relational database system to store information about the
animals that they have so that they can be matched up with animals at other zoos in a
breeding programme.

Figure 1 shows the structure of the relations in the database.

Figure 1

Zoo(ZooName, Town, Country)


AnimalLocation(AnimalID, ZooName, DateArrived, DateLeft)
Animal(AnimalID, IndividualName, Species, DateOfBirth, Sex)
Match(AnimalFemaleID, AnimalMaleID, DateOfMatch, Successful)

• The Zoo relation stores details of the zoos that participate in the breeding
programme. Each zoo is uniquely identified by its ZooName.
• The AnimalLocation relation identifies which zoos each animal has lived at. The zoo
that the animal is currently at can be identified because the DateLeft attribute is set
to 01/01/0001 to indicate that the animal has not left.
• The Animal relation stores details of the individual animals that are available to be
matched with other animals for breeding. Each animal is identified by a unique
number, the AnimalID. The individual name of the animal (eg ‘Timothy’) is also
stored, together with the species of the animal (eg ‘Red Panda’), its date of birth and
its sex (‘Male’ or ‘Female’).
• The Match relation stores details of matches that have been made. The attributes
AnimalFemaleID and AnimalMaleID refer to the AnimalID values of the two matched
animals in the Animal relation.

(a) Shade one lozenge to identify which of the properties below does not have to be
true for a fully normalised database.

A Each attribute in a relation is dependent on the primary key.

B Each attribute in a relation is dependent only on the primary


key; it is not also dependent on any other attribute in the
relation.
C The primary key in each relation consists of only one
attribute.
D There are no repeating groups (or equivalently each attribute
is atomic).
(1)

(b) Figure 2 is an incomplete entity-relationship diagram for part of the database shown
in Figure 1.

Draw lines on Figure 2 to indicate the degree of the two relationships between the
three entities shown in the entity-relationship diagram.

Figure 2

Page 1 of 27
(2)

(c) Complete the following SQL statement to create the Animal relation, including the
key field.

CREATE TABLE Animal (______________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

__________________________________________________________________)
(3)

(d) Figure 1 is repeated below to help you answer part (d).

Figure 1 (repeated)

Zoo(ZooName, Town, Country)


AnimalLocation(AnimalID, ZooName, DateArrived, DateLeft)
Animal(AnimalID, IndividualName, Species, DateOfBirth, Sex)
Match(AnimalFemaleID, AnimalMaleID, DateOfMatch, Successful)

There is a requirement to identify all of the red pandas that were present at the zoo
called ‘Ashdale Park’ at any time between 01/04/2020 and 31/05/2020, inclusive.

The animals might still be at the zoo or may have moved to another zoo.

Write a query that will list all the red pandas that were at the zoo on any day
between these dates.

For each red panda on the list, the animal’s individual name and the date that the
animal arrived at the zoo, and no other fields, should be listed.

___________________________________________________________________

Page 2 of 27
___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(7)

(e) It is proposed that an additional attribute, ZooName, is added to the Animal relation.
This will store the name of the zoo that currently has the animal. No other changes
would be made to the database.

Describe one advantage and one disadvantage of adding this new attribute to the
relation.

Advantage _________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

Disadvantage _______________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(2)
(Total 15 marks)

Q2.
A sports centre uses a relational database to store information about its facilities (such as
the swimming pool) and the bookings that have been made to use them.

The code below shows the structure of the relations in the database.

Page 3 of 27
Facility(FacilityID, Description, MaxPeople, PricePerHour)
FacilityForSport(Sport, FacilityID)
Booking(FacilityID, BookingDate, StartTime, EndTime, CustomerID)
Customer(CustomerID, Forename, Surname, EmailAddress)

• The Facility relation stores the different facilities available at the sports centre. Each
one is identified by a unique number and has a brief description. For example, the
facility with FacilityID 1 has the description ‘Outdoor Pitch A’. PricePerHour is the
price of hiring a facility for 1 hour. For example, the facility with FacilityID 1 has a
price per hour of £17.50.
• The FacilityForSport relation identifies which facilities are suitable for which sports.
For example, the facility with FacilityID 1 is suitable for football, rugby and hockey
and would therefore require three separate records in this relation.
• The Booking relation stores the bookings that have been made. Bookings must start
and end either on the hour, at quarter past, half past or quarter to the hour. A
customer can make bookings for more than one facility for the same time. For
example, a badminton club secretary might book both of the indoor sports halls for
the same time. However, each facility can only be booked by one customer at any
one time.
• The Customer relation stores the details of customers who have made bookings.

(a) The entity identifier (primary key) for the Booking relation is a composite entity
identifier, consisting of these three attributes:

FacilityID, BookingDate, StartTime

An alternative entity identifier could have been chosen, composed of different


attributes.

Shade one lozenge to indicate which of the following groups of attributes would form
a valid alternative entity identifier for the Booking relation.

A BookingDate, StartTime, EndTime

B FacilityID, BookingDate, EndTime

C FacilityID, StartTime, CustomerID

D FacilityID, BookingDate, EndTime, Sport


(1)

(b) A different design was originally proposed for the database. This design did not have
the Customer relation and had the following design for the Booking relation:

Booking(FacilityID, BookingDate, StartTime, EndTime, Forename, Surname,


EmailAddress)

Explain why this alternative design would have been rejected in favour of the design
in the code above.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

Page 4 of 27
___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(2)

(c) Complete the following SQL statement to create the Facility relation specified in the
code above, including the primary key.

CREATE TABLE Facility (____________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

__________________________________________________________________)
(3)

The code above is repeated below to help you answer part (d) without having to turn back
in the question paper.

Facility(FacilityID, Description, MaxPeople, PricePerHour)


FacilityForSport(Sport, FacilityID)
Booking(FacilityID, BookingDate, StartTime, EndTime, CustomerID)
Customer(CustomerID, Forename, Surname, EmailAddress)

(d) A customer wants to book a facility that is suitable for playing basketball on the
15/06/2021 between 14:15 and 16:15

As part of the booking process, a query is needed to list all the existing bookings
that would overlap with the new booking.

Write a query that will list all the bookings for facilities that are suitable for playing
basketball and which would overlap with the booking that the customer wants to
make.

For each booking which would overlap with the new booking only the FacilityID,
StartTime and EndTime fields should be listed.

___________________________________________________________________

___________________________________________________________________

Page 5 of 27
___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(7)
(Total 13 marks)

Q3.
An estate agency makes details of the properties that it has for sale available to potential
customers through a website. The details of the properties and other data that are useful
to the agency are stored in a relational database.

The individual web pages about specific properties that a customer can view are
generated dynamically by a program from the data in the database.

A client-server system, which uses CRUD and REST, is used to provide details of
properties in a web page that is being viewed in a web browser on a client computer.

Figure 1 shows the structure of the relations in the database.

Figure 1

Property(PropertyID, HouseNum, Street, Area, Postcode, Bedrooms,


Bathrooms, AskingPrice, SellerID)
Seller(SellerID, Title, Forename, Surname, Telephone)
Buyer(BuyerID, Title, Forename, Surname, Telephone, DesiredArea,
MinBedrooms, MaxPrice)
Viewing(BuyerID, PropertyID, ViewingDate, ViewingTime)
Sale(SaleID, PropertyID, BuyerID, SalePrice)

• The Property relation stores details of the properties that are for sale. This includes
the number of bedrooms and the number of bathrooms that a property has.
• The Seller relation stores details of people who are selling the properties.
• The Buyer relation stores details of the people who are looking to buy a property
and information about the type of property they want, including the area that they
want to live in, the minimum number of bedrooms that they need in a property and
the maximum price that they are prepared to pay.
• An entry is made in the Viewing relation whenever a buyer arranges to look at a
property.

Page 6 of 27
• An entry is made in the Sale relation whenever a property is sold to a buyer. The
SalePrice may be different to the AskingPrice for the property.

(a) The list below contains four statements about the principles of CRUD and REST.
One of these statements is false.

Shade one lozenge to indicate which statement is false.

CRUD is an acronym for Create, Retrieve, Update,


A
Delete.
REST allows JavaScript to communicate with the
B
server using the HTTP protocol.
The database is connected to the web browser using
C
REST.
The REST API will be created and run on the client
D
computer.
(1)

An SQL query is executed to retrieve some details about properties with at least four
bedrooms in a particular area. The following two records are found:

PropertyID HouseNum Street Bedrooms


8026 12 Chester Drive 4
9034 23a Castle Street 5

These records could be sent from the server to the client using XML or JSON.

Figure 2 shows the query results encoded using each of these methods.

Figure 2

Representation 1 Representation 2
{"Properties":[ <Properties>
{ "PropertyID": 8026, <Property>
"HouseNum": "12", <PropertyID>8026</PropertyI
D>
"Street": "Chester
Drive", <HouseNum>12</HouseNum>
"Bedrooms": 4 }, <Street>Chester
Drive</Street>
{ "PropertyID": 9034,
<Bedrooms>4</Bedrooms>
"HouseNum": "23a",
</Property>
"Street": "Castle
Street", <Property>
"Bedrooms": 5 } <PropertyID>9034</PropertyI
D>
]}
<HouseNum>23a</HouseNum>
<Street>Castle
Street</Street>
<Bedrooms>5</Bedrooms>
</Property>
</Properties>

Page 7 of 27
(b) Shade one lozenge to identify the method of encoding used by Representation 2.

A JSON

B XML
(1)

(c) State two reasons why it could be argued that JSON is better than XML.

Reason 1 __________________________________________________________

___________________________________________________________________

___________________________________________________________________

Reason 2 __________________________________________________________

___________________________________________________________________

___________________________________________________________________
(2)

(d) A composite primary key has been selected for the Viewing relation. This consists of
the attributes BuyerID, PropertyID and ViewingDate.

In selecting these attributes to form the primary key, what assumption has the
database designer made about the behaviour of the buyers?

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(1)

Figure 1 is repeated below so that you can answer part (e) without having to turn back in
the question paper.

Figure 1

Property(PropertyID, HouseNum, Street, Area, Postcode, Bedrooms, Bathrooms,


AskingPrice, SellerID)
Seller(SellerID, Title, Forename, Surname, Telephone)
Buyer(BuyerID, Title, Forename, Surname, Telephone, DesiredArea, MinBedrooms,
MaxPrice)
Viewing(BuyerID, PropertyID, ViewingDate, ViewingTime)
Sale(SaleID, PropertyID, BuyerID, SalePrice)

(e) Write an SQL query that will retrieve from the database the list of all properties that
the buyer with BuyerID 23 might be interested in buying. The properties should:

• be in the buyer’s desired area


• have at least the minimum number of bedrooms the buyer requires
• cost no more than the maximum price that the buyer is prepared to pay.

Page 8 of 27
The list of properties returned should only include, for each property, the following
details:

• the PropertyID
• the street that the property is on
• the number of bedrooms that the property has
• the asking price for the property.

The list should be ordered with the most expensive property at the top of the list and
the least expensive at the bottom of the list.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(5)
(Total 10 marks)

Q4.
A warehouse stores products that are waiting to be delivered to supermarkets. The
products are packed onto pallets. For example, a pallet might hold 120 boxes of washing
powder. All of the products on one pallet are of the same type.

The individual products on the pallets could be identified by labelling them individually with
barcodes or by attaching RFID (radio-frequency identification) tags to them.

Each barcode/RFID tag would store a representation of a ProductID number that uniquely
identifies the type of product (eg 102546 might represent a specific brand and box size of
washing powder) together with an ItemID number that is unique to the specific item (eg
box number 1 of the washing powder, box number 2 of the washing powder etc).

Figure 1 shows an example of five boxes of washing powder loaded onto a pallet and
their ProductID and ItemID values.

Figure 1

Page 9 of 27
Figure 2 shows an excerpt from the simple database table that stores the details of the
products that the warehouse has in stock.

Figure 2

ProductID Description QuantityInStock


102546 Washing Powder 1kg box 10 000
398352 Baked Beans 455g tin 1450
293820 Large Dishcloths 300

Some pallets delivered to the warehouse will be of products that already exist in the
database table. Other deliveries will be of pallets of items that don’t exist in the table
because the warehouse has not stocked them before.

(a) Explain why the warehouse owners might prefer the individual products to be
identified using RFID tags.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(2)

(b) Explain why the product manufacturers or supermarket owners might prefer the
individual products to be identified using barcode labels.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(2)

(c) Describe how an RFID reader would read the ProductID and ItemID values from
RFID tags as pallets are delivered and explain how this data could be used to
update the database table that stores details of the products that the warehouse has
in stock.

Page 10 of 27
You should include in your description references to the type(s) of SQL statements
(eg INSERT, SELECT, UPDATE) that could be used and their purpose, but you do
not need to write any SQL code.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(6)
(Total 10 marks)

Q5.
A veterinary practice with four different surgeries intends to use a relational database box
to store the data that it needs to manage its business.

Customers of the practice are pet owners who bring their pets to one of the surgeries for
appointments. The surgeries are staffed by vets.

• Each customer is identified by a unique identity number and the customer’s


forename, surname and telephone number are recorded.

• Each pet is identified by a unique identity number and the pet’s name, type and date
of birth are recorded.

• Each surgery is identified uniquely by its name. The town in which it is located and
the surgery’s telephone number are recorded.

• Each vet is identified by a unique identity number and the vet’s forename and
surname are recorded.

A pet is owned by one or more customers and each customer may own any number of
pets. Over their lifetimes, pets may attend many appointments.

To make an appointment for a pet, a customer contacts a surgery. The appointment is


made for the pet to take place on a particular date and time at a specific surgery.

Each vet is associated with one surgery which they work at; each surgery is staffed by
several vets.

Page 11 of 27
(a) Complete the entity-relationship diagram below for a fully normalised relational
database to store the data required by the veterinary practice.

Some of the entities and relationships have been drawn for you. You need to draw
the remaining three entities and clearly show the relationships between the entities
and their degree.

(3)

(b) Develop a fully normalised design for a relational database to store the
information required by the veterinary practice. To help you, the Pet, Surgery and
Vet relations have already been defined in Figure 1.

Figure 1

Using the format shown in the information above list all the other relations that will
need to be created, together with the attributes that each will contain.

Underline the attribute(s) that will form the entity identifier (primary key) in each
relation.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

Page 12 of 27
(4)

(c) The SQL query in Figure 2 has been written to produce a list of all of the vets who
work at the surgery in the town of Torquay. Some errors have been made in the
query.

Figure 2

Describe two errors that have been made in the query. You should not give the
omission of a semi-colon (;) as one of the errors.

Error 1 _____________________________________________________________

___________________________________________________________________

___________________________________________________________________

Error 2 _____________________________________________________________

___________________________________________________________________

___________________________________________________________________
(2)

(d) The database is stored at the practice’s head office. Staff at the individual surgeries
access it using a client-server database system, which enables the management of
concurrent access to the database.

Describe an example of a problem that could occur if no system were in place to


manage concurrent access to the database.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(3)
(Total 12 marks)

Page 13 of 27
Q6.
Two methods that can be used to manage concurrent access are:

• record locks
• timestamp ordering.

Select one of these methods and describe how it manages concurrent access.

Method selected: _________________________________________

How it works ____________________________________________________________

_______________________________________________________________________

_______________________________________________________________________

_______________________________________________________________________

_______________________________________________________________________

_______________________________________________________________________

_______________________________________________________________________

_______________________________________________________________________
(Total 2 marks)

Q7.
Employees at a bank use client computers to access data that is stored on a database
server.

The database server uses software to query and modify data stored in a database on hard
disk drives. It returns the results of these queries to the clients over the bank’s computer
network.

The performance of the system is unsatisfactory: the time-delay between a client sending
a query to the server and the client receiving the results is unacceptably long.

Explain how the performance of the system might be improved. You should consider the
following factors that might be affecting the performance:

• the hardware of the server


• the design of the computer network
• the database and software running on the server.

In your answer you will be assessed on your ability to follow a line of reasoning to produce
a coherent, relevant and structured response.
(Total 12 marks)

Q8.
Athletes, who are members of teams, compete in running events, which are held at
fixtures throughout the year.

For example, athlete 15 might compete in the Girls’ 1500m Under 18 race in the fixture at
Marsten on 12 September 2018.

Page 14 of 27
A relational database is used to store the details of which athletes enter each event at
each fixture. The relations used in the database are shown in Figure 1.

Figure 1

Athlete(AthleteID, Surname, Forename, DateOfBirth, Gender, TeamName)


EventType(EventTypeID, Gender, Distance, AgeGroup)
Fixture(FixtureID, FixtureDate, LocationName)
EventAtFixture(FixtureID, EventTypeID)
EventEntry(FixtureID, EventTypeID, AthleteID)

• Each Athlete, EventType and Fixture is identified by a unique identity number, for
example AthleteID for athletes.
• An EventType is a type of event, such as Boys’ 100m Under 15 race.
• If an athlete wants to take part in an event at a particular fixture, then an entry is
created in the EventEntry relation to represent this.

(a) Figure 2 shows an incomplete entity-relationship diagram for part of the database.

Draw lines on Figure 2 to show the degree of any three relationships that exist
between the four entities shown.

(2)

(b) Figure 3 shows an SQL statement that is intended to make a table to represent the
Athlete relation. The statement contains some errors.

Figure 3

CREATE TABLE Athlete (


PRIMARY KEY AthleteID,
VARCHAR(50) Surname,
VARCHAR(30) Forename,
DATE DateOfBirth,
VARCHAR(6) Gender,
VARCHAR(30) TeamName
)

You may assume that all of the data types used in Figure 3 are valid and the field
lengths are appropriate.

State two errors that have been made.

Error 1: ____________________________________________________________

Page 15 of 27
___________________________________________________________________

___________________________________________________________________

Error 2: ____________________________________________________________

___________________________________________________________________

___________________________________________________________________
(2)

(c) State two reasons why database designs, such as this one, are usually normalised.

Reason 1: __________________________________________________________

___________________________________________________________________

___________________________________________________________________

Reason 2: __________________________________________________________

___________________________________________________________________

___________________________________________________________________
(2)

Figure 1 is repeated below.

Figure 1 (repeated)

Athlete(AthleteID, Surname, Forename, DateOfBirth, Gender, TeamName)


EventType(EventTypeID, Gender, Distance, AgeGroup)
Fixture(FixtureID, FixtureDate, LocationName)
EventAtFixture(FixtureID, EventTypeID)
EventEntry(FixtureID, EventTypeID, AthleteID)

A list is to be produced of the names of all athletes who are competing in the fixture
that is taking place on 17/09/18. The list must include the Surname, Forename and
DateOfBirth of these athletes and no other details. The list should be presented in
alphabetical order by Surname.

(d) Write an SQL query to produce the list.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

Page 16 of 27
___________________________________________________________________
(5)
(Total 11 marks)

Q9.
A garage services and repairs cars. It uses a relational database to keep track of the jobs
that customers have booked for it to carry out. The database includes jobs that have been
completed and jobs that are waiting to be done.

The details of the jobs that the garage does, together with the parts that it stocks and uses
are stored in the database using the four relations shown in Figure 1.

Figure 1

Job (JobID, CarRegNo, JobDate, InGarage, JobDuration)


Car (CarRegNo, Make, Model, OwnerName, OwnerEmail,
OwnerTelNo)
Part (PartID, Description, Price, QuantityInStock)
PartUsedForJob (JobID, PartID, QuantityUsed)

• Each car has a unique CarRegNo.


• A type of car can be uniquely identified by the combination of its Make and Model.
Different Makes may use the same Model name and a particular manufacturer
(Make) will produce several different car Models.
• A booking made for a car on a particular date counts as one job, regardless of how
many different tasks are completed upon it.
• A job might require the use of any number of parts, including zero.
• Some of the details are stored in the database as soon as a booking is made and
others are only added when a job has been completed.

The attribute JobID is the Entity Identifier (Primary Key) of the Job relation.

(a) If the JobID attribute were not included in the Job relation, which other attribute or
attributes that are currently in the relation could probably be used as an Entity
Identifier (Primary Key) instead?

___________________________________________________________________
(1)

It has been suggested that the owner details (OwnerName, OwnerEmail, OwnerTelNo)
should not be stored in the Car relation and that a new relation should be created to store
owner details separately from car details.

(b) Explain why storing the owner details separately would improve the design of the
database.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

Page 17 of 27
(2)

(c) On the incomplete Entity-Relationship diagram below show the degree of any three
relationships that exist between the entities.

Job Car

Part PartUsedForJob
(2)

When an appointment is made for a job, this is represented in the Job relation. At the time
of booking, the InGarage attribute is set to False and the JobDuration attribute is set to
0:00. When the car arrives at the garage the value of the InGarage attribute is changed to
True. When the job is finished the value of the JobDuration attribute is updated to indicate
how long the job took and details of the parts used are recorded in the database.

The Job with JobID 206 has been completed. The job took 1 hour 30 minutes (1:30) and
used two of the parts with PartID 12.

(d) Write the SQL commands that are required to record the amount of time that the job
took in the database.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(3)

(e) Write the SQL commands that are required to record in the database the fact that
two of the parts with PartID 12 were used.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(2)

Figure 1 is repeated below.

Job (JobID, CarRegNo, JobDate, InGarage, JobDuration)


Car (CarRegNo, Make, Model, OwnerName, OwnerEmail,
OwnerTelNo)
Part (PartID, Description, Price, QuantityInStock)

Page 18 of 27
PartUsedForJob (JobID, PartID, QuantityUsed)

A mechanic needs to produce a list of all of the parts used on the job with JobID 93 for a
customer.

This list must include the PartID, Description, Price (each) and QuantityUsed of each part,
and no other details. The parts in the list should be ordered by PartID with the parts with
the lowest PartIDs nearest to the top of the list.

(f) Write an SQL query to produce the list.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(5)

There are restrictions on which parts can be fitted to which cars. For example:

• The driver’s door mirror with PartID 104 can only be fitted to one particular make
and model of car.
• The ignition switch with PartID 27 can be fitted to any model of car for one particular
make as the maker uses the same ignition switch in all models.
• The tyre with PartID 97 can be fitted to a wide range of cars of different makes and
models as it is a standard size.

If the information about which parts could be fitted to which makes and models of cars
were represented in the database, it could be used to help a mechanic identify the correct
parts to use for a job.

(g) Explain how the database design could be modified to represent which makes and
models of car a part can be fitted to.

___________________________________________________________________

___________________________________________________________________

Page 19 of 27
___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(3)
(Total 18 marks)

Q10.
A company is building an e-commerce website. The website will display details of the
products that the company sells and allow customers to place orders. Customers must
register on the website before they can place an order and each order can be for one or
more different products.

The product, customer and order details will be stored in a relational database.

It was originally proposed that the following three relations were required:

Product(ProductNumber, ProductPrice, ProductDescription, QuantityInStock)

Order(OrderNumber, OrderDate, CustomerID, OrderingComputerIPAddress,


ProductNumber, Quantity)

Customer(CustomerID, CustomerName, Address, Postcode, EmailAddress,


PaymentCardNumber)

The computer programmer identified a problem with the Order relation and stated that it
should be divided up into two separate relations:

Order(OrderNumber, OrderDate, CustomerID, OrderingComputerIPAddress)

OrderLine(OrderNumber, ProductNumber, Quantity)

(a) Describe the problem that the programmer identified with the original Order relation
and explain what the cause of this problem was.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(2)

(b) Complete the Entity-Relationship diagram below to show the degree of any three

Page 20 of 27
relationships that exist between the entities in the improved database design.

Customer Product

Order OrderLine
(3)

A web page is required that will display a summary of the products that are on a particular
order.

The summary must include only the ProductNumber, ProductDescription, ProductPrice


and the Quantity of the product that has been ordered. These must be displayed in
ascending order of ProductDescription.

(c) Write an SQL query that will find the data needed to produce the order summary
web page for order number 97.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(5)
(Total 10 marks)

Q11.
A parcel delivery company uses a relational database to store information about the
deliveries that it makes. These details include information about each customer who
sends a parcel, the individual parcels being delivered and pricing details.

The company offers three different service speeds, which are "Express", "Standard" and
"Economy". The price that is charged for delivering a parcel depends upon the service
speed selected and the weight of the parcel (to the nearest gram). For each service
speed, parcel prices are split into bands for a range of weights. For example, for the

Page 21 of 27
"Express" service, the price bands are as follows:

Minimum Weight (g) Maximum Weight (g) Price

0 249 £1.99

250 499 £2.99

500 999 £3.99

1000 4999 £4.99

5000 19999 £9.99

Similar price bands, but with different prices, exist for the "Standard" and "Economy"
services.

The details are stored using the three relations in the figure.

Customer(CustomerID, Title, Forename, Surname)

PriceBand(ServiceSpeed, MinWeight, MaxWeight, Price)

Parcel(ParcelID, ServiceSpeed, Weight, DateSent, CustomerID, RecipientName,

HouseNumber, Street, Town, County, Postcode)

(a) On the incomplete Entity-Relationship diagram below, show the degree of the three
relationships that exist between the entities.

(2)

(b) The price that is charged for an "Express" delivery, weighing between 1000 and
4999 grams is to be increased to £5.99. Complete the SQL statements below to
make this update.

UPDATE ____________________________________________________________

SET _______________________________________________________________

WHERE _____________________________________________________________

___________________________________________________________________
(4)

(c) Write a query that will list all of the parcels sent by the customer whose CustomerID
is 109.

Page 22 of 27
For each parcel, the list should include the DateSent, the Postcode that the parcel
was sent to, the ServiceSpeed that was used and the Price charged, and no other
details.

The list should be presented in order, with the parcel sent the longest time ago at
the top of the list and the parcel sent most recently at the bottom.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(6)

The figure is repeated below to help you answer part (d).

Customer(CustomerID, Title, Forename, Surname)

PriceBand(ServiceSpeed, MinWeight, MaxWeight, Price)

Parcel(ParcelID, ServiceSpeed, Weight, DateSent, CustomerID, RecipientName,

HouseNumber, Street, Town, County, Postcode)

(d) The Street, Town and County parts of a recipient’s address can all be identified
from the Postcode.

This means that the Parcel relation is not normalised and contains redundant data.

Redesign the Parcel relation, and create any new relations that you think are
necessary, to eliminate this redundancy from the database to produce a normalised
design.

Use the same notation that has been used in the figure when answering this
question part. Make sure that you underline the attribute(s) that make up the primary
key in each relation.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

Page 23 of 27
___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(3)
(Total 15 marks)

Q12.

A school stores information about its sports day in a relational database.

The details of the track events are stored using the three relations in Figure 1 .

Figure 1

Athlete (AthleteNumber, Forename, Surname, Class, Gender,


DateOfBirth)

Race (RaceNumber, Gender, Distance, Type, StartTime)

RaceEntryAndResult (RaceNumber, AthleteNumber, TimeSet)

Each athlete who takes part in a race is given a unique AthleteNumber. Athletes can run
in more than one race. If they do, they keep the same AthleteNumber for the entire day.

Many races are run throughout the day. An example race would be the boys 80m hurdles,
the third race of the day, which starts at 13:30. The entry in the Race table for this race is
shown in the table:

RaceNumber Gender Distance Type StartTime

3 Boys 80 Hurdles 13:30

When an athlete is entered into a race, a record of the entry is created in the
RaceEntryAndResult table. Initially, the TimeSet is recorded as 00:00.00 (meaning 0
minutes, 0 seconds, 0 hundredths of a second) to indicate that the race has not yet been
run. After the race has been run, if the athlete successfully completes it, then their
TimeSet value is updated to record the time that they achieved in minutes, seconds and
hundredths of a second. The TimeSet value remains at 00:00.00 for athletes who fail to
complete the race.

The primary keys in the Athlete and Race relations have been identified in Figure 1 by
underlining them. The correct primary key for the RaceEntryAndResult relation has not
been identified.

(a) In Figure 2 below, underline the appropriate attribute name(s) to identify the correct
primary key for this relation.

Page 24 of 27
Figure 2

RaceEntryAndResult (RaceNumber, AthleteNumber, TimeSet)

(1)

(b) Relations in a database should usually be fully normalised.

Define what it means for a database to be fully normalised.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(2)

(c) On the incomplete Entity-Relationship diagram below show the degree of the three
relationships that exist between the entities.

RaceEntryAndRe
Athlete
sult

Race

(2)

(d) Athlete number 27 is to be entered into race number 6.

Write the SQL commands that are required to make this entry.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(2)

(e) Figure 1 is repeated below.

Figure 1 (repeated)

Athlete (AthleteNumber, Forename, Surname, Class, Gender,


DateOfBirth)

Race (RaceNumber, Gender, Distance, Type, StartTime)

Page 25 of 27
RaceEntryAndResult (RaceNumber, AthleteNumber, TimeSet)

Athlete number 27 sets a time of 0:18.76 (0 minutes, 18 seconds, 76 hundredths of


a second) for race number 6.

Write the SQL commands that are required to update the athletes entry for this race,
to store this time in the TimeSet field.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(3)

(f) The competition organisers want to produce a list of all of the athletes who took part
in race number 6 with the athlete who won (set the lowest time) at the top and the
other athletes below the winner in the order in which they finished.

Only athletes who finished the race should be included in the list.

The following information should appear for each athlete: AthleteNumber,


Forename, Surname and TimeSet.

Write an SQL query to produce the list.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(5)

(g) The database system is to be extended for use in an inter-school athletics league.
Users at any school in the county will be able to access the system to input the
results of races.

It is possible that two users might try to access or update the system at the same
time.

Explain the conditions under which simultaneous access to a database could cause

Page 26 of 27
a problem, and how this could be dealt with.

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________

___________________________________________________________________
(3)
(Total 18 marks)

Page 27 of 27

You might also like