Databases
Databases
JUNE 2012
1
A database is designed to store data about students at a college and the subjects that they
study.
The following table StudentSubjects was a first attempt at the database design.
Table: StudentSubjects
StudentName
Tom
TutorGroup
6
Tutor
SAN
Joe
MEB
Samir
SAN
Subject
Physics
Chemistry
Gen. Studies
Geography
French
Computing
Chemistry
Maths
Gen. Studies
Level SubjectTeacher
A
SAN
A
MEB
AS
DIL
AS
ROG
AS
HEN
A
VAR
A
MEB
A
COR
A
DIL
(a) (i) Explain why the table is not in First Normal Form (1NF).
[1]
(ii) Explain your answer by referring to the above data.
[1]
Using the data given in the original table, show how this data is now stored in the
revised table designs.
Table: Student
StudentName
TutorGroup
Tutor
Table: StudentSubjectChoices
StudentName
Subject
Level
SubjectTeacher
[3]
[2]
(ii) A student is not allowed to choose the same subject at A Level and AS.
What is the primary key of table StudentSubjectChoices?
[1]
[2]
[2]
[2]
JUNE 2012
A database is designed to store data about all aircraft owned by an airline and the flight
schedules.
The following table AircraftSchedule was a first attempt at part of the database design.
Table: AircraftSchedule
AircraftID
1
Type
747
YearBought
1998
747-400
2007
747-400
2007
FlightCode
2032
1187
1326
1556
1426
1427
5564
7865
1090
1165
Departure
Delhi
Singapore
Melbourne
Tokyo
Bristol
Amsterdam
Bristol
Rome
London
New York
Arrival
Singapore
Melbourne
Tokyo
Delhi
Amsterdam
Bristol
Rome
Istanbul
New York
Boston
(a) (i) Explain why the table is not in First Normal Form (1NF).
[1]
(ii) Explain your answer in terms of the data above.
[1]
Type
YearBought
[1]
(ii) How many records are now stored in table Schedules?
[1]
[2]
(ii) What is the primary key of table Aircraft?
[1]
[2]
(ii) State what foreign key needs to be added to the Schedules table design.
[1]
[2]
[1]
NOVEMBER 2012
[2]
(ii) Explain how keys are used to implement a one-to-many relationship between the
two entities X and Y shown below:
Entity X
Entity Y
[3]
(b) A company has a number of products for sale and receives orders from customers.
Customers are given a CustomerID and other customer data are recorded
Each product has a ProductID and other product data are recorded
Over a period of time a customer will place many orders, and each product can
appear on many customer orders
You should assume:
o all orders are for one product only,
o on any given day a customer will place at most one order.
Customer(CustomerID,
Product(ProductID,
[2]
[2]
(ii) Give the attributes for the Order table, showing the primary key.
You should not create an OrderID for this table.
Order(
[2]
NOVEMBER 2012
[2]
(ii) Explain how keys are used to implement the one-to-many relationship between the
two entities X and Y shown below.
Entity X
Entity Y
[3]
,
,
)
)
[3]
(ii) A third table, CourseEnrolment, will record which employee enrolled on which
courses.
State two essential attributes for this table. Show the primary key.
You should not create a CourseEnrolmentID for the table.
CourseEnrolment(
[2]
(c) Storing data in flat files has been replaced by storing data in relational database tables.
Explain how the use of a relational database reduces data redundancy.
[2]
NOVEMBER 2012
[2]
(ii) Explain how keys are used to implement a one-to-many relationship between the
two entities X and Y shown below:
Entity X
Entity Y
[3]
(b) A College library has a stock of books which are loaned to students.
Each book has a BookID and other data about each book are recorded
Each student has a StudentID starting with the year of entry e.g. 2010jamesd
Other data about each student are also recorded
When a loan is made data are recorded. Any book may be loaned by a particular
student more than once.
However, you can assume that the same book is never loaned out to the same student
on the same day.
A table description can be expressed as:
TableName(Attribute1, Attribute2, Attribute3, ...)
The primary key is indicated by underlining one or more attributes.
(i) Describe the given data model by adding two attributes to the Student table and
two attributes to the Book table.
,
Student(StudentID,
Book(BookID,
[2]
[2]
(ii) Give the attributes for the Loan table below, showing the primary key.
You should not create a LoanID for this table.
Loan (
[2]
JUNE 2013
A hospital has a number of doctors and a number of wards. A ward has a number of
patients. A patient may be treated by more than one doctor and a doctor treats many
patients.
Data is to be recorded in a relational database and the tables include DOCTOR and
PATIENT.
(a) (i) What is the relationship between DOCTOR and PATIENT?
[1]
(ii) Show this relationship with an entity-relationship (E-R) diagram.
[1]
(iii) Draw an E-R diagram showing a database design which can be produced so that
the doctor and patient data are fully normalised.
[4]
[1]
[2]
[2]
JUNE 2013
A database is created to store data about all the football clubs who play in a number of
different leagues.
Each club runs a number of different teams (Men, Women, Boys, Girls).
Each club has a number of players.
A player can only be registered with one club.
Each club team plays in a league.
Data is to be recorded in a relational database and the tables include CLUB and LEAGUE.
(a) (i) What is the relationship between CLUB and LEAGUE?
[1]
(ii) Show this relationship with an entity-relationship (E-R) diagram.
[1]
(iii) Draw an E-R diagram showing a database design which can be produced so that
the club and league data are fully normalised.
[4]
[1]
[2]
[2]
NOVEMBER 2013
8
A runner must be registered with one club only and club names are unique.
A club has runners; each runner has a unique national MemberID.
Each race is organised by a club and the Club Secretary records which runners are
entered for each race.
Runners may enter any race.
There is only one race on any one day.
At present each club records the data for the competition races it organises. The data is
stored in flat files.
(a) Describe three advantages that a relational database would have over the use of flat
files.
1
3
[3]
[2]
[1]
(ii) Is this table in Second Normal form (2NF)?
Explain.
[1]
(iii) The table is not in Third Normal Form (3NF).
Explain.
[1]
(iv) Using only the attributes given in the RUNNER table above, produce a new design
which is fully normalised.
The table descriptions should be expressed as:
TableName(Attribute1, Attribute2, Attribute3, ...)
[2]
(e) Explain why all tables in the final design should be fully normalised.
[2]
(f) The table to store the race data has the following design:
RACE(RaceDate, RaceStartTime, StartVenue, Distance,
OrganisingClubName)
Write a Data Manipulation Language (DML) query to report all races after the 1st
January 2013 which are less than 10 km. Display the race date and organising club
name only.
Use the keywords SELECT, FROM, WHERE.
[3]
NOVEMBER 2013
9
At present the company stores and manages all the data using flat files.
(a) Describe three advantages that a relational database would have over the use of flat
files.
1
3
[3]
[2]
[2]
[1]
(ii) Is this table in Second Normal form (2NF)?
Explain.
[1]
(iii) The table is not in Third Normal Form (3NF).
Explain.
[1]
(iv) Using only the attributes given in the PRODUCT table above, produce a new design
which is fully normalised.
The table descriptions should be expressed as:
TableName(Attribute1, Attribute2, Attribute3, ...)
[2]
(e) Explain why all tables in the final design should be fully normalised.
[2]
(f) The table to store the order data has the following design:
ORDER(OrderNo, OrderDate, OrderTime, IsPaid, OrderAmountPaid,
PaymentMethod, CustomerID)
Write a Data Manipulation Language (DML) query to report orders which were placed
on the 15 January 2013 and paid for using a debit card. Show the customer ID and
order number only.
Use the keywords SELECT, FROM, WHERE.
[3]
NOVEMBER 2013
At present the company records all car, customer and hire data in flat files.
(a) Describe three advantages that a relational database would have over the use of flat
files.
1
3
[3]
[2]
[2]
[1]
(ii) Is this table in Second Normal form (2NF)?
Explain.
[1]
(iii) The table is not in Third Normal Form (3NF).
Explain.
[1]
(iv) Using only the attributes given in the CAR table above, produce a new design
which is fully normalised.
The table descriptions should be expressed as:
TableName(Attribute1, Attribute2, Attribute3, ...)
[2]
(e) Explain why all tables in the final design should be fully normalised.
[2]
(f) The table to store the hire data has the following design:
HIRE(HireID, CarRegistrationNo, HireBookingDate, HireStartDate,
NoOfDays, HireRate, CustomerID)
Write a Data Manipulation Language (DML) query to report all hire bookings made for
car registration 456431 with customer C674. Display the customer ID and hire ID only.
Use the keywords SELECT, FROM, WHERE.
[3]
JUNE 2014
11 A company hires vehicles to customers. A database is to be created to record data for all hire
transactions.
The company has a number of depots in different towns. Each town has one depot only. A
number of vehicles are available for hire. Each vehicle is based at one of the depots. Every
vehicle starts and ends a hire from its base depot.
Depot data consist of:
Depot town name
Depot address
Vehicle data consist of:
A unique registration number
A vehicle type code. Vehicles are coded as SC Small Car, LC Large Car or V Van.
Vehicle mileage
Customer data consist of:
Unique Customer ID
Customer address
Data for each hire transaction consist of:
Customer ID
Vehicle registration number
Date the booking was made
Start date of the hire
Return date
Driving licence check. A check is carried out to confirm that customers have a valid driving
licence and this is recorded. This check is done when the customer shows their driving
licence when they collect the vehicle.
Hire charge
(a) At first, the company used a single table named DepotVehicle. A sample of the tables
data is shown below.
DepotTown
RegistrationNo
VehicleType
0987
SC
0988
SC
0991
0945
1431
SC
1476
LC
Dhaka
Kumba
[2]
Depot
Vehicle
Customer
Hire.
[1]
(ii) Complete the description for the Vehicle and Depot tables using the notation:
TableName(Attribute1, Attribute2, )
where the underlined attribute indicates the primary key.
Vehicle(
Depot(
[4]
(c) The Customer and Hire tables (with the primary keys not shown) are as follows:
Customer(CustomerID, CustomerAddress)
Hire(CustomerID, DateBooked, RegistrationNo,
StartDate, ReturnDate, LicenceChecked, HireCharge)
Consider the relationship between Customer and Hire.
(i) Draw the E-R diagram.
[1]
(ii) Explain how this relationship between Customer and Hire is modelled using the given
attributes.
[2]
[2]
(e) A query is needed to list the depot and registration number for all small car vehicles.
Write the query in Data Manipulation Language (DML).
[3]
(f) On 05/04/2014, customer 085 booked a vehicle hire. This hire will start on 13/04/2014.
When the customer arrives, the receptionist will check their driving licence. If the licence is
valid, the value of the licence check attribute, of the correct Hire record, must be updated.
Complete the Data Manipulation Language (DML) command to make the change.
UPDATE Hire
SET
WHERE CustomerID = '085' AND
[2]
JUNE 2014
12 Paintings by various artists are on display in art galleries all over the world. When a gallery holds
an exhibition, it may display paintings:
A database is to be created. It will store data about artists, paintings, galleries and exhibitions.
Artist data consist of:
artist name (unique).
Painting data consist of:
When a gallery lends a painting to another gallery, it may charge a loan fee.
The database design consists of five entities. These are shown in the entity-relationship
(E-R) diagram.
Gallery
Exhibition
Features
ExhibitionPainting
Owns
Painting
Artist
Paints
[1]
(ii) Complete the description for the Gallery and Exhibition tables. Use the notation:
TableName(Attribute1, Attribute2, ...)
where the underlined attribute indicates the primary key.
Gallery (
Exhibition (
)[4]
(b) The Painting and ExhibitionPainting entities (with the primary keys not shown) are
as follows:
Painting(PaintingRefNo, PaintingTitle, ArtistName, PaintingDate,
GalleryName)
ExhibitionPainting(ExhibitionTitle, PaintingRefNo, LoanFee)
(i) What is the primary key of table ExhibitionPainting?
[1]
Consider the relationship between Painting and ExhibitionPainting.
(ii) Draw this relationship on the E-R diagram.
[1]
(iii) Explain how this relationship is modelled using the given attributes.
[2]
[2]
(d) Write a DML query to display the painting reference number and painting title for all paintings
by Da Vinci.
[3]
(e) The painting The Guitar Player was in the Secrets and Silence exhibition. The
ExhibitionPainting table has a record for this. In the record:
);
[3]
(a) (i) The table/each student has a repeated group of attributes // each student has a number
of subjects
[1]
(ii) StudentName, TutorGroup and Tutor would need to be repeated for each record
(b)
Table: Student
StudentName TutorGroup
Tom
Joe
Samir
6
7
6
Table: StudentSubjectChoices
Tutor
Student
Subject
Name
SAN
Tom
Physics
MEB
Tom
Chemistry
SAN
Tom
Gen Studies
Joe
Geography
Joe
French
Samir
Computing
Samir
Chemistry
Samir
Maths
Samir
Gen. Studies
Level
A
A
AS
AS
AS
A
A
A
A
[1]
Subject
Teacher
SAN
MEB
DIL
ROG
HEN
VAR
MEB
COR
DIL
[1]
[1]
[1]
[1]
[MAX 2]
[2]
[Total: 14]
(a) (i)
The table has a repeated group of attributes // each aircraft has a repeated group of
attributes
[1]
(ii) AircraftID, Type and YearBought would have to be repeated for all records // FlightCode,
Departure and Arrival are the repeated group
[1]
(b) (i) The Aircraft table would contain:
AircraftID
Type
YearBought
747
1998
747400
2007
747400
2007
[1]
(ii) 10 records
[1]
[1]
[2]
[1]
[2]
(a) (i)
[2]
[3]
(b) (i) -Two sensible attributes for Customer (but none which relate to the Product or Order tables)
-Two sensible attributes for Product (but none which relate to the Customer or Order
tables)
[2]
(ii) -Order attributes include CustomerID + ProductID
-Primary key of CustomerID + OrderDate
[2]
[2]
[Total: 11]
(a) (i)
[2]
[MAX 3]
(b) (i) Two sensible attributes for Employee (and do not relate to the Course or
CourseEnrolment tables)
CourseCode shown as the primary key
One sensible non-key attribute for Course (and does not relate to the Employee or
CourseEnrolment tables)
(ii) EmployeeID, CourseCode
Primary key of EmployeeID + CourseCode
[3]
[2]
[2]
[Total: 12]
(a) (i)
[2]
[3]
(b) (i) -Two sensible attributes for Student (but none which relate to the Book or Loan tables)
- Two sensible attributes for Book (but none which relate to the Student or Loan tables)
[2]
(ii) Loan table
-Loan attributes include StudentID and BookID
-Primary key StudentID_+ BookID + IssueDate
[2]
(a) (i)
Many-to-many
[1]
[1]
(iii)
[1]
2 one-to-many relationships
[1]
[1]
[1]
[1]
[1]
(c) The primary key of table WARD - WardName
[1]
[1]
[1]
[1]
[Total: 12]
(a) (i)
[1]
[1]
(iii)
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[Total: 12]
[1]
[1]
[1]
[1]
(c) (i)
[1]
[1]
[1]
[1]
(iii) There are dependent non-key attributes // ClubAddress is dependant on ClubName [1]
(iv) RUNNER(MemberID, RunnerName, RunnerDOB, ClubName)
CLUB(ClubName, ClubAddress)
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[1]
(c) (i)
[1]
[1]
[1]
[1]
[1]
[1]
[1]
(iv) PRODUCT(ProductID,
ProductDescription,
RetailPrice,
SupplierID)
[1]
SUPPLIER(SupplierID, SupplierName, SupplierTelNumber)
[1]
[1]
[1]
[1]
MAX 2
[1]
[1]
[1]
10 (a)
(b) (i) many cars are hired to many customers // many-to-many // M:m
(ii)
[1]
[1]
(c)
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[1]
[Total: 19]
11 (a)
(1)
(1)
[2]
(b) (i)
[1]
(ii)
(1)
[4]
(c) (i)
[1]
(ii)
(d)
(e)
(f)
(1)
(1)
[2]
(1)
(1)
[2]
(1)
(1)
(1)
[3]
UPDATE Hire
SET LicenceChecked = TRUE // YES // equivalent
(1)
(1)
[2]
12 (a) (i)
[1]
(1)
(1)
(1)
(1)
[4]
[1]
(ii)
[1]
[2]
(1)
(1)
[2]
(1)
(1)
(1)
[3]
(1)
(1)
(1)
[3]