Databases and SQL – IGCSE Computer Science (0478)

14 questions · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
1
0478/22/F/M/26 · Question 8Feb/March 2026Paper 2211 marks
Loading question…
Question text

8
A database table NATIONAL_TREES stores details of the national trees of some countries from
around the world.
IDCode
Country
Continent
CommonName
ScientificName
EU121
Albania
Europe
Olive
Olea europaea
OC235
Australia
Oceania
Golden wattle
Acacia pycnantha
NO126
The Bahamas
North America
Lignum vitae
Guaiacum sanctum
AS534
Bangladesh
Asia
Mango tree
Mangifera indica
SO326
Brazil
South America
Brazilwood
Caesalpinia echinata
NO124
Canada
North America
Maple
Acer
EU321
Cyprus
Europe
Golden oak
Quercus alnifolia
NA456
Dominican Republic
North America
West Indian mahogany
Swietenia mahagoni
EU652
Finland
Europe
Silver birch
Betula pendula
AS222
India
Asia
Indian banyan
Ficus benghalensis
NO232
Jamaica
North America
Blue mahoe
Talipariti elatum
AF875
Madagascar
Africa
Baobab
Adansonia
OC123
New Zealand
Oceania
Silver fern
Cyathea dealbata
AS498
Philippines
Asia
Narra
Pterocarpus indicus
AF501
South Africa
Africa
Real yellowwood
Podocarpus Iatifolius
SO522
Venezuela
South America
Araguaney
Tabebuia chrysantha
(a) State the number of fields and records in this database table.
fields …
records …
[2]
(b) The data in both IDCode and Country fields are unique in the database table.
State one reason why IDCode would make a better primary key than Country
…
… [1]
© Cambridge University Press & Assessment 2026
,
,
(c) Give the output that would be produced by the structured query language (SQL) statement:
SELECT IDCode, Country, CommonName
FROM NATIONAL_TREES
WHERE Continent = "Europe";
…
…
…
…
…
… [3]
(d) Complete the SQL statement to list only the country, common name and scientific name of
the national trees listed for North America, in alphabetical order of their common names.
SELECT …
FROM …
WHERE …
… ;
[5]
© Cambridge University Press & Assessment 2026

2
0478/22/F/M/25 · Question 8Feb/March 2025Paper 2211 marks
Loading question…
Question text

8
A database table, MajorCity, stores some details about a number of cities from around the
world.
Code
City
Capital
Country
Continent
Population
ASY6
Abu Dhabi
TRUE
United Arab Emirates
Asia
1,566,999
EUY3
Amsterdam
TRUE
Netherlands
Europe
1,174,025
ASY1
Beijing
TRUE
China
Asia
21,766,214
SAY1
Buenos Aires
TRUE
Argentina
South America
15,490,415
AFY1
Cairo
TRUE
Egypt
Africa
22,183,200
EUN1
Frankfurt
FALSE
Germany
Europe
796,437
ASY3
Jakarta
TRUE
Indonesia
Asia
11,248,839
ASN3
Karachi
FALSE
Pakistan
Asia
17,236,230
ASY4
Kuala Lumpur
TRUE
Malaysia
Asia
8,621,724
AFN2
Lagos
FALSE
Nigeria
Africa
15,945,912
SAY2
Lima
TRUE
Peru
South America
11,206,000
EUY1
London
TRUE
UK
Europe
9,648,110
EUY4
Madrid
TRUE
Spain
Europe
6,751,374
ASN2
Mumbai
FALSE
India
Asia
21,296,516
NAN1
New York City
FALSE
USA
North America
7,888,121
EUY2
Paris
TRUE
France
Europe
11,206,000
ASN1
Shanghai
FALSE
China
Asia
29,210,808
ASY5
Singapore
TRUE
Singapore
Asia
6,080,859
AUN1
Sydney
FALSE
Australia
Australia
5,120,894
ASY2
Tokyo
TRUE
Japan
Asia
37,194,104
NAN2
Toronto
FALSE
Canada
North America
6,371,958
EUN2
Valencia
FALSE
Spain
Europe
838,301
SAN1
Valencia
FALSE
Venezuela
South America
1,983,445
(a) State the number of fields and records in this database table.
Fields …
Records …
[2]
ĬÑĊ®Ġ´íÈõÏĪÅĊÞùµĀ×
,
,
(b) Identify the field in the database table that is most suitable to be the primary key and give
one reason for your choice.
Primary key field …
Reason …
…
[2]
(c) Give the output from the structured query language (SQL) statement:
SELECT City, Country, Population
FROM MajorCity
WHERE Continent = "South America"
ORDER BY Population;
…
…
…
…
…
… [3]
(d) Complete the SQL statement to list only the code, city, country and continent of all the cities
in the database table that are capital cities.
SELECT …
…
…
… [4]
ĬÓĊ®Ġ´íÈõÏĪÅĊÞûµĀ×

3
0478/22/F/M/24 · Question 9Feb/March 2024Paper 228 marks
Loading question…
Question text

9
A storage unit rental company wants to set up a new database table for the storage units that can
be rented.
The table is called StorageUnits and needs to store these details:
•
SizeMetres – size in square metres
•
Position – first, second or third floor
•
Hoist – whether there is a hoist available for the transfer of items
•
PriceMonth – the price in dollars for a month’s rental
•
StorageID – the code to identify each storage unit, for example S123
(a) (i)
Give the name of the field that would be used for the primary key.
… [1]
(ii)
State the reason for choosing this field for the primary key.
…
… [1]
(b) Complete the table to identify the most appropriate data type for these fields in the table
StorageUnits
Field
Data type
SizeMetres
Position
Hoist
StorageID
[2]
(c) Complete this structured query language (SQL) statement to display only the storage code,
price and size in square metres of all the storage units where there is a hoist available.
SELECT …
FROM …
WHERE … ;
[4]

Advertisement
4
0478/22/F/M/23 · Question 9Feb/March 2023Paper 229 marks
Loading question…
Question text

9
A shop that sells books has set up a new database table called BookList to store book details.
Part of this table is given.
CatNo
Title
Fiction
Author
PaperBack
Price StockLevel
BK01
The Princes’ Story
Yes
B Penn
Yes
4.50
500
BK02
The Princesses’ Story
Yes
B Penn
Yes
4.50
350
BK03
Computer Science
No
Way Yu
Yes
19.99
20
BK04
The Modern World
No
P Patel
No
25.00
5
BK05
The Ancient World
Yes
P Patel
No
25.00
5
BK06
Computer Science
No
R Dale
Yes
27.35
8
BK07
The Princes’ Story
Yes
B Penn
No
12.50
3
BK08
The Princesses’ Story
Yes
B Penn
No
12.50
0
BK12
Famous Five
Yes
E Bly
Yes
2.75
45
BK15
Secret Seven
Yes
E Bly
Yes
2.75
25
BK16
The Last Knight
Yes
P Mann
Yes
5.99
7
BK17
The Dark Tower
Yes
P Mann
Yes
5.99
5
BK19
The Final Chase
Yes
P Mann
Yes
5.99
5
BK21
Maths Today Part 1
No
B Ward
Yes
6.75
25
BK22
Maths Today Part 2
No
B Ward
Yes
6.75
15
BK23
Maths Today Part 3
No
B Ward
Yes
6.75
10
BK26
Maths Today Workbook
No
B Ward
Yes
6.75
30
BK27
Knitting for Beginners
No
A Smith
Yes
6.99
3
BK30
Woodwork for Beginners
No
A Smith
Yes
6.99
4
BK31
Networking for Beginners
No
A Smith
Yes
6.99
0
(a) State the number of records in this part of the database table.
… [1]
(b) (i)
Give the name of the field that would be used for the primary key.
… [1]
(ii)
State the reason for choosing this field for the primary key.
…
… [1]
(c) Complete the table to identify the most appropriate data type for each field based on the data
shown in the table BookList
Field
Data type
CatNo
Title
Fiction
Price
[2]
(d) Write the output from this structured query language (SQL) statement.
SELECT CatNo, Title, Author
FROM BookList
WHERE StockLevel = 0;
…
…
…
… [2]
(e) Complete this SQL statement to display all the titles by the author B Penn.
SELECT …
FROM …
WHERE … ;
[2]

5
0478/22/F/M/22 · Question 2Feb/March 2022Paper 228 marks
Loading question…
Question text

2
An algorithm has been written to:
•
input the ages of 100 students
•
count and output the number of students aged 7 and under 12
•
count and output the number of students aged 12 and under 18
•
count and output the number of students aged 18 and over.
(a) Complete the pseudocode algorithm:
←
0
01
Count7to12
←
0
02
Count12to18
←
0
03
CountOver18
←
1 TO …
04
FOR Student
05
OUTPUT "Please enter student's age in years "
06
INPUT Age
07
IF Age >= 7 …
08
THEN
←
Count7to12 + 1
09
Count7to12
10
ENDIF
11
IF Age >= 12 AND Age < 18
12
THEN
←
…
13
Count12to18
14
ENDIF
15
IF Age >= 18
16
THEN
←
CountOver18 + 1
17
CountOver18
18
ENDIF
19
NEXT Student
20
OUTPUT "There are ", Count7to12, " students aged 7 and under 12."
21
OUTPUT "There are ", Count12to18, " students aged 12 and under 18."
22
OUTPUT "There are ", … , " students aged 18 and over."
[4]
(b) Write the extra pseudocode statements that are needed to count and output the number of
students under the age of 7. Use the variable CountUnder7; assume CountUnder7 has
already been set to zero.
…
…
…
…
…
…
… [4]

6
0478/22/F/M/22 · Question 5Feb/March 2022Paper 226 marks
Loading question…
Question text

5
A database table, FLOWER, is used to keep a record of the type of flowers available to make up a
bouquet.
FlowerID
Type
Colour
Style
Fragrance
CN001
Carnation
Pink
Stem
Y
CN002
Carnation
Red
Stem
N
CN103
Carnation
White
Stem
N
CN104
Carnation
Yellow
Stem
Y
CN105
Carnation
Pink
Spray
Y
CN106
Carnation
Red
Spray
N
CN107
Carnation
White
Spray
N
CN108
Carnation
Yellow
Spray
Y
RE101
Rose
Pink
Stem
Y
RE102
Rose
Red
Stem
Y
RE103
Rose
White
Stem
N
RE104
Rose
Yellow
Stem
Y
RE105
Rose
Orange
Spray
Y
RE106
Rose
Peach
Spray
N
LY101
Lily
White
Spray
Y
A query-by-example has been written to display just the type, style and colour of all flowers that
have no fragrance.
Field:
FlowerID
Fragrance
Style
Colour
Table:
FLOWER
FLOWER
FLOWER
FLOWER
Sort:
Show:
3
3
3
3
Criteria:
= Y
or:
Explain why the query-by-example is incorrect and write a correct query-by-example.
Explanation …
…
…
…
…
Field:
Table:
Sort:
Show:
Criteria:
or:
[6]
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

7
0478/22/F/M/20 · Question 2Feb/March 2020Paper 228 marks
Loading question…
Question text

2
(a) An algorithm has been written in pseudocode to input 50 numbers. Positive numbers are
stored in the array PosNum[ ]. Negative numbers are stored in the array NegNum[ ].
Zeros are not included in the positive and negative counts.
←
0
Count
←
Count
PosCount
←
Count
NegCount
REPEAT
INPUT Number
IF Number > 0
THEN
←
PosCount + 1
PosCount
←
Number
PosNum[PosCount]
ELSE
←
NegCount + 1
NegCount
←
Number
NegNum[NegCount]
ENDIF
←
Count + 1
Count
UNTIL Count >= 50
OUTPUT "There are ", PosCount," positive numbers"
OUTPUT "There are ", NegCount," negative numbers"
Describe the error in the pseudocode and write the correction for this error.
Error …
…
…
…
Correction …
…
…
…
[4]
(b) The algorithm needs to be changed so there is no limit to how many numbers can be input.
When the number 9999 is input, the algorithm stops more numbers being input and outputs
the results. The number 9999 is not to be stored nor counted as a positive number.
Explain how you would change the algorithm.
…
…
…
…
…
…
…
…
…
… [4]

8
0478/22/F/M/20 · Question 5Feb/March 2020Paper 2210 marks
Loading question…
Question text

5
A database table, BOX, is used to keep a record of boxes made and sold by a craftsman. Boxes
are categorised by:
•
SIZE – small, medium or large
•
SHAPE – brief description for example ‘star shaped’
•
WOOD – maple, beech, walnut or ebony
•
PRICE – price in $
•
SOLD – whether the box is sold or not.
A database management system uses these data types:
Text
Number
Currency
Boolean
(a) Select the most appropriate data type for each field from the four types shown. State the
reason why you chose the data type.
SIZE data type …
Reason …
…
SHAPE data type …
Reason …
…
WOOD data type …
Reason …
…
PRICE data type …
Reason …
…
SOLD data type …
Reason …
…
[5]
(b) (i)
Complete the query-by-example grid below to only display the price of small walnut
boxes.
Field:
Table:
Sort:
Show:
Criteria:
or:
[3]
(ii)
The query-by-example grid from part (b)(i) needs to be changed to show both walnut
and beech boxes and display the wood used. Only one column needs to be changed.
Write the changed column.
Field:
Table:
Sort:
Show:
Criteria:
or:
[2]
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

Advertisement
9
0478/22/F/M/19 · Question 2Feb/March 2019Paper 226 marks
Loading question…
Question text

2
(a) An algorithm has been written in pseudocode to input 50 numbers and total only the positive
numbers.
←
1
Count
←
Count
Total
REPEAT
INPUT Number
IF Number <> 0
THEN
←
Total + Count
Total
ENDIF
←
Count + 1
Count
UNTIL Count < 50
PRINT Total
Find the four errors in the pseudocode and suggest a correction for each error.
Error 1 …
Correction …
…
Error 2 …
Correction …
…
Error 3 …
Correction …
…
Error 4 …
Correction …
…
[4]
(b) Show how you would change the corrected algorithm to only total numbers greater than 0
and less than 20.
…
…
… [2]
Question 3 starts on page 10.

10
0478/22/F/M/19 · Question 4Feb/March 2019Paper 224 marks
Loading question…
Question text

4
For each of the four groups of statements in the table, place a tick in the correct column to show
whether it is an example of Selection or Repetition.
Statements
Selection
Repetition
← 1 TO 10
FOR X
← SUM + 1
SUM
NEXT X
WHILE X > 10 DO
←
SUM
SUM + 1
←
X - 1
X
ENDWHILE
IF X > 10
THEN
←
SUM + 1
SUM
←
X - 1
X
ENDIF
REPEAT
←
SUM
SUM + 1
←
X - 1
X
UNTIL X > 10
[4]

11
0478/22/F/M/19 · Question 6Feb/March 2019Paper 224 marks
Loading question…
Question text

6
A database table, BIKETYRES, is used to keep a record of tyres for sale in a cycle shop.
Tyres are categorised by width and diameter in millimetres, whether they have an inner tube and
the type of terrain for which they are designed.
Tyre Code
Width
Diameter
Tube
Terrain
Stock Level
SLTT
23
700
YES
Asphalt
18
MLNT
24
700
NO
Asphalt
23
LLNT
28
700
NO
Asphalt
19
SLTM
23
700
YES
Mixed
22
MLTM
24
700
YES
Mixed
14
LLTM
28
700
YES
Mixed
12
SLTH
23
700
YES
Hard
10
MLTH
24
700
YES
Hard
5
LLNH
28
700
NO
Hard
7
SLNM
23
700
NO
Mixed
12
MLNM
24
700
NO
Mixed
22
LLNM
28
700
NO
Mixed
18
SSNT
23
650
NO
Asphalt
10
MSNT
24
650
NO
Asphalt
8
SSTM
23
650
YES
Mixed
5
MSNM
24
650
NO
Mixed
4
The query-by-example grid below displays the tyre code and the stock level of all 28 mm width
tyres suitable for mixed terrain.
Field: Tyre Code
Stock Level
Width
Terrain
Table: BIKETYRES
BIKETYRES
BIKETYRES
BIKETYRES
Sort:
Show:
3
3
Criteria:
= 28
= 'Mixed'
or:
Alter the query to show the tyre code and stock level in ascending order of stock level for all
24 mm asphalt terrain tyres. Write the new query in the following query-by-example grid.
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

12
0478/22/F/M/18 · Question 6Feb/March 2018Paper 2212 marks
Loading question…
Question text

6
A database table, JEWEL, is used to keep a record of jewellery for sale in a shop. Each item of
jewellery can be made of silver, platinum or gold metal. The shop stocks rings, bracelets and
necklaces. The number in stock and the price is also stored.
(a) Identify the four fields required for the database. Give each field a suitable name and data
type. Explain why you chose the data type for each field.
Field 1 Name … Data type …
Explanation …
…
Field 2 Name … Data type …
Explanation …
…
Field 3 Name … Data type …
Explanation …
…
Field 4 Name … Data type …
Explanation …
…
[8]
(b) Explain why none of these fields could be used as a primary key.
…
… [1]
(c) Using the query-by-example grid below, write a query to identify the silver bracelets. Only
display the number in stock and the price.
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 International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local

13
0478/22/F/M/17 · Question 5Feb/March 2017Paper 228 marks
Loading question…
Question text

5
(a) Rewrite the following pseudocode algorithm using a WHILE … DO … ENDWHILE loop.
INPUT Num
FOR Counter ← 1 TO 12
Num ← Num * Counter
A[Counter] ← Num
NEXT
…
…
…
…
…
…
…
…
…
… [4]
(b) Explain the differences between a WHILE … DO … ENDWHILE and a REPEAT … UNTIL
loop.
…
…
…
…
…
…
…
… [4]

Advertisement
14
0478/22/F/M/17 · Question 6Feb/March 2017Paper 226 marks
Loading question…
Question text

6
A database table, DEVICE, has been set up to record the electronic equipment used in a small
business.
Device ID
Device Type
User
Purchase
Purchase
Portable
Date
Price ($)
3
Desktop
Alan Swales
14/02/2017
1350.00
N
4
Laptop
Chantel Law
01/02/2016
1460.00
Y
5
Tablet
Abdula Saud
31/12/2016
1000.00
Y
6
Desktop
Abdula Saud
14/03/2017
1000.00
N
7
Laptop
Alan Swales
15/03/2016
1700.00
Y
8
Tablet
Taona Jaji
16/12/2016
470.00
Y
(a) The query-by-example grid below selects certain records.
Field:
User
Portable
Purchase Price ($)
Table:
DEVICE
DEVICE
DEVICE
Sort:
Ascending
Show:
3
Criteria:
Y
>1000
or:
Show what would be the output from the query-by-example.
…
…
… [2]
(b) Complete the query-by-example grid below to select all Desktop devices that were either
purchased before 31/12/2016 or cost under $1000. Only show the Device ID and Device
Type.
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 International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local

Advertisement