Databases and SQL – A Level Computer Science (old syllabus, to 2021) (9608)
Quick quiz: 10 random questions from this topic. Answer them all, then open the Summary.
Question text
7
A movie theatre has a relational database that stores the movie schedule, and information about
the movies. The theatre has several screens that play movies at the same time.
The database has three tables to store information about the movies, the screens and the movie
schedule.
MOVIE(MovieID, Title, Length, Rating)
SCREEN(ScreenNumber, NumberSeats)
MOVIESCHEDULE(ScheduleID, MovieID, ScreenNumber, Time)
(a) Complete the entity-relationship (E-R) diagram to show the relationships between these
tables.
MOVIE
SCREEN
MOVIESCHEDULE
[2]
(b) Explain how primary and foreign keys are used to link the tables in the movie theatre
database.
…
…
…
…
…
…
… [4]
(c) The database needs to store the name of the company that produced each movie, for
example, Rocking Movies.
Write an SQL script to add the attribute ProductionCompany to the MOVIE table.
…
…
…
…
… [2]
(d) Write an SQL script to display the title and rating of all movies scheduled to play on screen
number 3.
…
…
…
…
…
…
…
…
…
Question text
2
A veterinary surgery cares for sick animals. The surgery has a file-based database that stores
data about the pets, their owners, and appointments made with the surgery.
The surgery wants to upgrade to a relational database.
(a) Explain the reasons why the surgery should upgrade their database.
…
…
…
…
…
…
…
… [4]
(b) The design for the surgery database, SURGERY, is:
PET(PetID, OwnerFirstName, OwnerLastName, PetName, PetBreed,
PetDateOfBirth, TelephoneNumber)
APPOINTMENT(AppointmentID, Date, Time, StaffID, PetID)
(i)
Give one reason why the database design for SURGERY is not in Third Normal Form
(3NF).
…
… [1]
(ii)
The database needs to be normalised to 3NF. A pet may have more than one owner and
an owner may have more than one pet.
The appointment table does not need to change and has been repeated below.
Give the name and attributes of three additional tables in 3NF. Identify the primary
key(s) in each table.
APPOINTMENT(AppointmentID, Date, Time, StaffID, PetID)
Table 1 …
…
…
Table 2 …
…
…
Table 3 …
…
…
[4]
(c) Part of the table APPOINTMENT is shown. The veterinary surgery uses Data Manipulation
Language (DML) statements to search for appointments.
AppointmentID
Date
Time
StaffID
PetID
222010
02/02/2021
12:40
JK1
20CF
222011
02/02/2021
12:40
PP2
10DT
222012
02/02/2021
12:50
JK1
9RR
222013
02/02/2021
13:00
JK1
Question text
9
A company uses a relational database.
(a) The company stores data about its customers and their bank details.
Explain the ways in which the database can be set up to only allow certain people to see the
bank details.
…
…
…
… [2]
(b) The database contains the following tables that store data about suppliers and stock.
SUPPLIER(SupId, SupName, SupAddress, SupPhone, SupContactName)
STOCK(StockId, SupId, StockName, StockImage, NumberInStock)
(i)
Write Data Manipulation Language (DML) statements to return the supplier name, phone
number and contact name, and the number of items in stock for the item with the stock
ID of D930.
…
…
…
…
…
… [4]
(ii)
The stock price needs to be included in the stock table.
$10.55 and $299.99 are two examples of stock prices.
Write Data Definition Language (DDL) statements to insert the attribute StockPrice
into the table STOCK.
…
…
…
… [2]
(c) Three examples of items stored in the data dictionary of a relational database are:
Item
Purpose
Field name
to store the names of fields so they cannot be repeated in a table
Primary key
to uniquely identify each record in a table
Validation rule
to ensure that data entered is sensible
Identify three other examples of items stored in a data dictionary and give the purpose of
each.
Item 1 …
Purpose …
…
…
Item 2 …
Purpose …
Question text
3
A Local Area Network is used by school staff who access data stored in a Database Management
System (DBMS).
(a) (i)
Explain the difference between security and privacy of data.
…
…
…
…
…
… [3]
(ii)
Give an example for this application where privacy of data is a key concern.
…
… [1]
(b) Name and describe two security measures the Network Manager has in place to protect the
security of the data held in the DBMS.
1 …
…
…
…
2 …
…
…
…
[4]
(c) A task for staff at the start of the school year is to key in new pupil data from a paper document.
The data is entered to a screen form and includes the data verification of some fields.
Describe what is meant by verification.
…
…
…
… [2]
Question text
2
A company writes applications (apps) for smartphones. The company has a relational database,
PURPLEGAME, which stores the information for one of its online game apps.
The database has three tables to store player’s details, dates when they have logged into the app
and in-app purchase details.
LOGIN(LoginID, PlayerID, Date)
PURCHASE(PurchaseID, PlayerID, PurchaseDate, Cost)
PLAYER(PlayerID, PlayerName, SkillLevel)
(a) Draw the entity-relationship (E-R) diagram to show the relationships between the three tables.
[2]
(b) The database manager is concerned about data integrity.
State what is meant by data integrity. Give an example of how the manager can ensure data
integrity in the PURPLEGAME database.
…
…
…
… [2]
(c) The database designer states that the PURPLEGAME database is in Third Normal Form (3NF).
Tick (3) one box to indicate whether this statement is true or false.
True
False
Justify your choice.
…
…
…
…
…
… [3]
(d) (i)
The following table shows some sample data for the PLAYER table.
PlayerID
PlayerName
SkillLevel
fly918
Kylie
3
elephant11
Mehrdad
9
candy22
Suzi
15
greenGrass
Jason
22
Write an SQL script to create the PLAYER table.
…
…
…
…
…
…
…
…
…
…
Question text
3
A company uses a relational database, EMPLOYEES, to store data about its employees and
departments.
(a) The company uses a Database Management System (DBMS).
(i)
The DBMS has a data dictionary.
Describe what the data dictionary stores.
…
…
…
… [2]
(ii)
The DBMS has a query processor.
Describe the purpose of a query processor.
…
…
…
… [2]
(b) Relationships are created between tables using primary and foreign keys.
Describe the role of a primary and a foreign key in database relationships.
…
…
…
… [2]
(c) In the company:
•
An employee can be a manager.
•
A department can have several managers and several employees.
•
An employee can only belong to one department.
The EMPLOYEES database has three tables:
EMPLOYEE_DATA( EmployeeID, FirstName, LastName, DateOfBirth, Gender,
DepartmentNumber)
DEPARTMENT(DepartmentNumber, DepartmentName)
DEPARTMENT_MANAGER(DepartmentNumber, EmployeeID, role)
Complete the entity-relationship (E-R) diagram for the EMPLOYEES database.
EMPLOYEE_DATA
DEPARTMENT_MANAGER
DEPARTMENT
[3]
(d) Give three reasons why the EMPLOYEES database is fully normalised.
1 …
…
2 …
…
3 …
…
[3]
(e) Part of the EMPLOYEE_DATA table is shown.
EmployeeID
FirstName
LastName
DateOfBirth
Gender
DepartmentNumber
156FJEK
Harvey
Kim
12/05/1984
Male
S1
558RRKL
Catriona
Moore
03/03/1978
Female
F2
388LMDV
Oscar
Ciao
01/01/1987
Male
F2
(i)
Write a Data Definition Language (DDL) statement to create the EMPLOYE
Question text
1
(a) Five descriptions and seven relational database terms are shown below.
Draw a line to link each description to its correct database term.
Description
Database term
Any object, person or thing about which
it is possible to store data
Secondary key
Candidate key
Dataset organised in rows and columns;
the columns form the structure and the
rows form the content
Entity
Any attribute or combination of attributes
Foreign key
that can act as a unique key
Primary key
Attribute(s) in a table that link to the
primary key in another table to form a
relationship
Table
Tuple
Attribute or combination of attributes that
is used to uniquely identify a record
[5]
(b) Explain what is meant by referential integrity.
…
…
…
…
…
… [3]
Question text
1
Some shops belong to the Rainbow Retail buying group. They buy their goods from one or more
suppliers.
Each shop has:
•
a unique shop ID
•
a single retail specialism (for example, food, electrical, garden).
Each supplier has:
•
a unique supplier ID
•
a similar single specialism recorded.
Rainbow Retail creates a relational database to record data about the shops and their suppliers.
The entity-relationship (E-R) diagram for the relationship between the SHOP and SUPPLIER tables
is shown.
SHOP
SUPPLIER
(a) Explain what the degree of relationship is between the entities SHOP and SUPPLIER.
…
… [1]
The database design is as follows:
SHOP(ShopID, ShopName, Location, RetailSpecialism)
SUPPLIER(SupplierID, SupplierName, ContactPerson, RetailSpecialism)
SHOP-SUPPLIER(ShopID, SupplierID)
The SHOP–SUPPLIER table stores the suppliers that each shop has previously used.
Primary keys are not shown.
(b) (i)
Label the entities and draw the relationships to complete the revised E-R diagram.
SUPPLIER
[3]
(ii)
Complete the following table to show for each database table:
•
the primary key
•
the foreign key(s) (if any):
° Each table may contain none, one or more foreign key(s).
° For a table with no foreign key, write ‘None’.
•
an explanation for the use of any foreign key.
Table
Primary key
Foreign key(s)
Explanation
(if any)
SHOP
SUPPLIER
SHOP–SUPPLIER
[5]
(iii)
The database designer has implemented SUPPLIER.ContactPerson as a secondary
key.
Describe the reason for this.
…
…
…
… [2]
(c) (i)
Write an SQL query to display the shop ID and location of all shops with a ‘GROCERY’
specialism.
…
…
… [3]
(ii)
The existing shop with ID 8765 has just used the existing supplier SUP89 for the first
time.
Write an SQL script to add this data to the database.
…
…
… [3]
Question text
6
Sheila creates a relational database for her hotel using a Database Management System (DBMS).
(a) Draw one line from each database term to its most appropriate description.
Database Term
Description
A field in one table that links to a primary key in another table
Primary key
A collection of records and fields
Attribute
The type of data that is being stored
A unique identifier for each tuple
Foreign key
A data item, represented as a field within a table
Entity
The concept or object in the system that we want to model
and store information about
[4]
(b) Identify three tasks that Sheila can perform using the DBMS developer interface.
1 …
2 …
3 …
[3]
(c) Sheila creates the database HOTEL with the following table structure:
ROOM(RoomNumber, RoomType)
BOOKING(BookingID, RoomNumber, CustomerID, StartDate)
CUSTOMER(CustomerID, FirstName, LastName, Address, Tel_Num)
(i)
The following table shows some sample data for the table ROOM.
RoomNumber
RoomType
1
Standard
2
Double
3
Executive
4
Standard
Complete the Data Definition Language (DDL) statement to create the table ROOM.
… TABLE ROOM(
RoomNumber Integer,
RoomType … ,
… (RoomNumber)
);
[3]
(ii)
Room number 5 is a Double room.
Complete the Data Manipulation Language (DML) statement to add the details for room
number 5 to the table ROOM.
INSERT … ROOM
VALUES( … );
[2]
(iii)
The table BOOKING needs an additional field to store the number of nights (for example,
3) a customer is staying.
Write a Data Definition Language (DDL) statement to add the new field to the table
BOOKING.
…
…
…
…
… [2]
Question text
9
An airline company uses a relational database to store data about passengers and flights.
Part of the database is shown.
PASSENGER(PassengerID, FirstName, LastName)
FLIGHT(FlightID, FlightDate, FlightTime)
PASSENGER_LIST(FlightID, PassengerID, SeatNo)
(a) Complete the entity-relationship (E-R) diagram to show the relationships between the given
tables.
PASSENGER
FLIGHT
PASSENGER_LIST
[2]
(b) The following is example data for the table FLIGHT:
FlightID
FlightDate
FlightTime
MO126
05/05/21
09:00
GK6708
06/09/21
00:30
BA0897
08/12/21
15:30
Write Data Definition Language (DDL) statements to define the table FLIGHT.
…
…
…
…
…
…
… [5]