Databases and SQL – O Level Computer Science (2210)
23 questions · page 1 of 2 · Clear filters
Question text
9
A swimming club wants to set up a new database table to store details of the members of the
club and the maximum distance each member swam in metres.
The table is called SWIMMERS and will contain these fields:
•
Distance – distance the member swam, for example 1500
•
Date – date the member swam the distance
•
Time – time taken to swim the distance
•
MemberID – the code to identify a member, for example TH749
•
MemberName – name of the member.
(a) (i)
State why MemberName would not be appropriate for a primary key.
…
… [1]
(ii)
Give the name of the most appropriate field for the primary key.
…
… [1]
(b) Complete the table to identify the most appropriate data type for these fields in the
table SWIMMERS. Each data type must be different.
field
data type
Distance
Date
MemberID
[2]
(c) Complete the structured query language (SQL) statement to display only the names of the
members who swam a distance of 1500 metres or more.
SELECT …
FROM …
WHERE …
… ;
[3]
© Cambridge University Press & Assessment 2026
,
,
© Cambridge University Press & Assessment 2026
Question text
9
(a) A database table CAR_PARTS stores details of car parts that a business has in stock.
Complete the table by giving the most appropriate data types for each field.
Only the data types: text, character, Boolean, integer, real and date/time are available in
this database.
field
data type
description
unique code to identify the car
PartID
part with letters and numbers
name of the car part, for example
PartName
windscreen wiper
four-digit number code to
CarType
represent the type of car
Price
selling price to 2 decimal places
specifies the size if relevant,
Size
otherwise stores ‘one size’
single letter code for the colour of
Colour
the car part
NumberInStock
the quantity of car parts in stock
whether or not the car part is
InStock
in stock
[4]
(b) Complete the structured query language (SQL) statement to list only the part ID, type of car
and the quantity in stock of all the car parts that are brake pads.
SELECT …
FROM …
WHERE … ;
[4]
(c) Describe one reason why the InStock field is not needed in the table.
…
…
…
… [2]
© Cambridge University Press & Assessment 2026
,
,
© Cambridge University Press & Assessment 2026
Question text
8
A bus company has set up a new database table called BUS to store details of the buses leaving
the main bus terminal.
RouteID
Destination
Stops
Driver
Time
Return
BC01
Town Centre
10
B Smith
9:00
Yes
BC02
The Fountain
5
A Patel
9:10
Yes
BC03
The Palace
9
B Hayes
9:28
No
BC04
City Park
12
W Gao
9:55
Yes
BC05
City Mall
9
R Hussein
10:10
No
BC06
Swan Lake
14
S Clarke
10:33
No
BC07
Guildhall Square
7
J Page
11:34
No
BC08
Sunset Quay
6
A Patel
12:01
Yes
BC10
Fort Worthington
15
E Carr
12:01
Yes
BC12
The Observatory
18
B Smith
13:27
No
BC14
East Seaport
11
B Scott
14:07
No
BC15
The Football Ground
12
J Page
14:46
Yes
BC19
The Cricket Ground
11
B Hayes
15:14
No
BC23
Temple Ruins
14
W Gao
16:16
No
BC27
The University
9
A Patel
16:45
No
(a) (i)
Identify one appropriate data type for the field Return
… [1]
(ii)
State the reason for the data type chosen.
…
… [1]
(b) Write the output from the structured query language (SQL) statement:
SELECT RouteID, Destination, Time
FROM BUS
WHERE Driver = "A Patel";
…
…
…
…
… [2]
ĬÑĊ®Ġ´íÈõÏĪÅĊßù¶Ā×
,
,
(c) Complete the SQL statement to display only the destination of the buses that have a return.
SELECT …
…
…
… [3]
Question text
A database table, CapitalCity, stores data about capital cities from around the world.
9
Field
Description
Identification
a unique identifier
Name
the name of the city
Country
the name of the country in which the city is located
Continent
the name of the continent in which the city is located
Population
the number of people living in the city
Founded
the year the city was founded
AverageIncome
average income of the city’s population, in $, rounded to 2 decimal places
Subway
whether or not the city has an underground railway system
(a) Complete the table by writing one appropriate field from CapitalCity for each data type.
Each field must be different.
Data type
Field
Boolean
integer
real
text
[2]
(b) Complete the structured query language (SQL) statement to list only the name, country and
population of all the cities in CapitalCity from the continent of Asia.
SELECT …
… CapitalCity
WHERE … = … ;
[4]
Due to an issue with Question 10, the question has been removed from the question paper.
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Question text
A database table called SoftDrinks stores details of the soft drinks sold by a small shop.
9
Field
Example data
Name
Cola
Supplier
Cambridge Beverages
Container
Can
SizeCl
330
NumberInStock
30
ReorderLevel
15
Reordered
Yes
(a) State whether any of the given fields would be suitable as a primary key and give a reason for
your answer.
…
… [1]
(b) Complete the structured query language (SQL) statement to return the number of cans the
shop has in stock.
SELECT … ( … )
FROM …
WHERE … = … ;
[5]
Question text
10 A television subscription service has a new database table named Contract to store details of
their subscribers’ contracts. The table contains these fields:
•
ContractNumber – the contract number, for example CT567
•
Months – the length of the contract in months, for example 6
•
EndDate – the date the contract finishes, for example 30 November 2024
•
News – the news service, yes or no
•
Movie – the movie service, yes or no
•
Sport – the sports service, yes or no
•
Junior – the children’s service, yes or no.
(a) Identify the field that will be the most appropriate primary key for this table.
… [1]
(b) Complete the table to identify the most appropriate data type for these fields in Contract
Field
Data type
ContractNumber
Months
EndDate
Sport
[2]
(c) Explain the purpose of these structured query language (SQL) statements.
Statement 1: SELECT SUM (Months) FROM Contract;
Statement 2: SELECT COUNT (News) FROM Contract WHERE News;
Statement 1 …
…
…
Statement 2 …
…
…
[3]
(d) Complete this SQL statement to find the contract numbers of the subscribers that take both
the news and sports services.
SELECT …
FROM Contract
WHERE … AND … ;
[2]
Question text
10 A database table called TVRange shows the main features and prices of a range of televisions.
TVCode
ScreenSize
Satellite
SmartTV
SoundBar
Price$
TV90SaSmSd
90
YES
YES
YES
9750.00
TV75SaSmSd
75
YES
YES
YES
8500.00
TV75SaSd
75
YES
NO
YES
8000.00
TV65SaSmSd
65
YES
YES
YES
6000.00
TV65SmSd
65
NO
YES
YES
5000.00
TV65SaSd
65
YES
NO
YES
5000.00
TV55SaSmSd
55
YES
YES
YES
4000.00
TV55SaSd
55
YES
NO
YES
3500.00
TV55SmSd
55
NO
YES
YES
3500.00
TV50SaSmSd
50
YES
YES
YES
2500.00
TV50Sa
50
YES
NO
NO
1750.00
TV50Sm
50
NO
YES
NO
1750.00
TV40Sa
40
YES
NO
NO
1200.00
TV40
40
NO
NO
NO
950.00
TV32
32
NO
NO
NO
650.00
(a) Give the name of the field that is most suitable to be the primary key.
State the reason for this choice.
Field …
Reason …
…
[2]
(b) The database uses the data types:
•
text
•
character
•
Boolean
•
integer
•
real
•
date/time.
Complete the table to show the most appropriate data type for each field.
Each data type must be different.
Field
Data type
TVCode
ScreenSize
SmartTV
Price$
[2]
(c) Complete the structured query language (SQL) query to return the television (TV) code,
screen size and price of all Smart TVs in the database table.
SELECT TVCode, … , …
… TVRange
WHERE SmartTV = … ;
[4]
Question text
10 A music streaming service has a new database table named Songs to store details of songs
available for streaming. The table contains the fields:
•
SongNumber – the catalogue number, for example AG123
•
Title – the title of the song
•
Author – the name of the song writer(s)
•
Singer – the name of the singer(s)
•
Genre – the type of music, for example rock
•
Minutes – the length of the song in minutes, for example 3.75
•
Recorded – the date the song was recorded.
(a) Identify the field that will be the most appropriate primary key for this table.
… [1]
(b) Complete the table to identify the most appropriate data type for the fields in Songs
Field
Data type
SongNumber
Title
Recorded
Minutes
[2]
(c) Explain the purpose of the structured query language (SQL) statements.
SUM (Minutes) FROM Songs WHERE Genre = "rock";
COUNT (Title) FROM Songs WHERE Genre = "rock";
…
…
…
…
…
… [3]
Question text
6
A computer game shop records its stock levels in a database table called GAMES. The fields used
in the stock table are shown.
Name
Description
GameID
primary key
GameName
the name of each game
AgeRestriction
the minimum age at which a person is allowed to play each game
GamePrice
the selling price for each game
NumberStock
the quantity of each game currently in stock
whether or not each game is on order from the suppliers
OnOrder
DateLastOrdered
the date the most recent order for each game was placed
GameDescription
a summary of the contents and purpose of each game
(a) State the number of fields that are in the table GAMES.
… [1]
(b) State one important fact that must be true for a field to be a primary key.
…
… [1]
(c) Complete the query-by-example grid to output all the games that have no stock and that are
on order with the supplier. Display only the GameID, GameName and GamePrice fields in
alphabetical order of the name of the game.
Field:
Table:
Sort:
Show:
Criteria:
or:
[3]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Question text
5
A database table, NURSE, is used to keep a record of disposable items worn by veterinary nurses.
This is part of the table:
ItemNumber
Description
SingleUse
Uses
StockLevel
ReorderLevel
DIG1
Glove (pair)
Y
1
500
800
DIA1
Apron
Y
1
700
800
DIM5
Hair net
Y
1
650
500
DIA2
Apron
N
5
25
100
DIS4
Suit
N
3
70
50
DIV9
Shoe cover (pair)
Y
1
400
250
(a) Complete this query-by-example grid to display only the item number and the description of
single use items, where the stock level is below the reorder level.
Field:
Table:
Sort:
Show:
Criteria:
or:
[4]
(b) Give a reason why the field SingleUse is not required in the table NURSE.
…
… [1]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Question text
6
A library uses a database table, GENRE, to keep a record of the number of books it has in each
genre.
ID
GenreName
Total
Available
Loaned
Overdue
ABI
Autobiography
500
250
250
20
BIO
Biography
650
400
250
0
EDU
Education
20200
10000
10200
1250
FAN
Fantasy
1575
500
1075
13
GFI
General Fiction
35253
23520
11733
0
GNF
General Non-Fiction
25200
12020
13180
0
HFI
Historical Fiction
6300
3500
2800
0
HNF
Historical Non-Fiction
8000
1523
6477
0
HUM
Humour
13500
9580
3920
46
MYS
Mystery
26000
13269
12731
0
PFI
Political Fiction
23561
10523
13038
500
PNF
Political Non-Fiction
1823
750
1073
23
REF
Reference
374
374
0
0
ROM
Romance
18269
16800
1469
0
SAT
Satirical
23567
12500
11067
0
SCF
Science Fiction
36025
25000
11025
0
SPO
Sport
45720
32687
13033
3256
THR
Thriller
86000
46859
39141
0
(a) State the reason ID could be used as a primary key in the table GENRE.
…
… [1]
(b) State the number of records in the table GENRE.
…
… [1]
(c) Complete the query-by-example grid to display any genres with overdue books. Only display
the ID, GenreName and Overdue fields in order of the number of books overdue from largest
to smallest.
Field:
Table:
Sort:
Show:
Criteria:
or:
[4]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Question text
6
A database table, PLANT, is used to keep a record of plants sold by a nursery. The table has these
fields:
•
NAME – name of plant
•
FLOWER – whether the plant flowers (True) or not (False)
•
POSITION – shade, partial shade or sun
•
SIZE – small, medium or large
•
PRICE – price in $
•
NUMBERSOLD – how many sold
A query-by-example grid has been completed to display only the price, name and number sold of
small plants that do not flower.
NAME
PRICE
NUMBERSOLD SIZE
FLOWER
POSITION
Field:
Table: PLANT
Sort:
Show:
3
3
3
Criteria:
= "shade"
or:
Identify the errors in the query-by-example grid.
…
…
…
…
…
…
Rewrite the corrected query-by-example grid.
Field:
Table:
Sort:
Show:
Criteria:
or:
[5]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Question text
6
A garden centre sells garden tools and stores details of these in a database table named TOOLS.
Code is the primary key in the TOOLS table.
Code
Description
Price ($)
Quantity_Stock
Quantity_Ordered
GFLG
Garden Fork
50.00
1
50
GSLG
Garden Spade
50.00
11
0
GHLG
Garden Hoe
45.00
8
0
HFSM
Hand Fork
9.99
42
0
HSSM
Hand Spade
9.99
40
0
HWSM
Hand Weeder
9.99
11
0
HS20
Hose (20 metres)
45.00
10
0
HS35
Hose (35 metres)
60.00
2
0
HS50
Hose (50 metres)
75.00
20
60
YBLG
Yard Brush
24.99
100
0
LMHD
Lawn Mower
99.99
5
0
LMBT
Lawn Mower (Battery)
249.99
7
0
LMPT
Lawn Mower (Petrol)
349.99
10
25
TRBT
Edge Trimmer (Battery)
79.99
15
0
TRPT
Edge Trimmer (Petrol)
59.99
20
0
SHSM
Shears
40.00
40
0
HCSM
Hedge Clippers
40.00
45
0
(a) State the purpose of the primary key in the TOOLS table.
…
…
… [1]
(b) List the output from the data shown in the table TOOLS that would be given by this query-by-
example.
Field:
Code
Description
Price ($)
Quantity_Stock
Quantity_Ordered
Table:
TOOLS
TOOLS
TOOLS
TOOLS
TOOLS
Sort:
Descending
Show:
ü
ü
ü
Criteria:
>40
>0
>0
or:
…
…
…
…
…
… [3]
(c) Complete the query-by-example grid to output the tools where the quantity in stock is below
25. Only show the Code, Description and Quantity_Stock fields in ascending order of Code.
Field:
Table:
Sort:
Show:
Criteria:
or:
[3]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Question text
5
The table, BEVERAGES, shows the number of calories in 100 ml of a range of popular beverages.
It also shows the availability of these drinks in a can, a small bottle and a large bottle.
BevNo
BevName
Calories
Can
Small Bottle
Large Bottle
Bev01
Cola
40
Yes
Yes
Yes
Bev02
Lime
45
Yes
No
Yes
Bev03
Energy Drink 1
52
Yes
Yes
No
Bev04
Energy Drink 2
43
Yes
No
No
Bev05
Mango
47
Yes
No
Yes
Bev06
Lemon Iced Tea
38
Yes
No
Yes
Bev07
Lemonade
58
Yes
Yes
Yes
Bev08
Orange Juice
46
Yes
Yes
No
Bev12
Apple Juice
50
Yes
Yes
No
Bev15
Chocolate Milk
83
Yes
Yes
No
(a) Give a reason for choosing BevNo as the primary key for this table.
…
… [1]
(b) State the number of records shown in the table BEVERAGES.
… [1]
(c) List the output that would be given by this query-by-example.
Field:
BevNo
BevName
Can
Small Bottle
Large Bottle
Table:
BEVERAGES
BEVERAGES
BEVERAGES
BEVERAGES
BEVERAGES
Sort:
Descending
Show:
ü
ü
Criteria:
= "Yes"
= "Yes"
= "Yes"
or:
…
…
…
… [3]
(d) Complete the query-by-example grid to output a list showing just the names and primary keys
of all the beverages with a calorie count greater than 45. The list should be in alphabetical
order of names.
Field:
Table:
Sort:
Show:
Criteria:
or:
[4]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Question text
6
A database table, FLIGHT, is used to keep a record of flights from a small airfield. Planes can
carry passengers, freight or both. Some flights are marked as private and only carry passengers.
Flight number
Plane
Notes
Departure time
Passengers
FN101
Caravan 1
Private passenger flight
08:00
Y
CN101
Caravan 2
Freight only
08:30
N
CN102
Piper 1
Freight only
09:00
N
FN104
Piper 2
Passengers only
09:20
Y
FN105
Piper 1
Freight and passengers
10:00
Y
FN106
Caravan 1
Passengers only
10:30
Y
CN108
Caravan 2
Freight only
08:00
N
CN110
Lear
Private passenger flight
08:00
Y
(a) State the field that could have a Boolean data type.
Field … [1]
(b) A query-by-example has been written to display just the flight numbers of all planes leaving
after 10:00 that only carry passengers.
Field:
Flight number
Passengers
Departure time
Table:
FLIGHT
FLIGHT
FLIGHT
Sort:
Show:
3
Criteria:
= Y
= 10:00
or:
Explain why the query-by-example is incorrect, and write a correct query-by-example.
Explanation …
…
…
…
…
Field:
Table:
Sort:
Show:
Criteria:
or:
[7]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of