Databases and SQL – IGCSE Computer Science (0478)
116 questions · page 2 of 8 · Clear filters
Question text
9
A database table, CapitalCity, stores data about capital cities from around the world.
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]
ĬÑĊ®Ġ´íÈõÏĪÅĊÝù·Ā×
Question text
1
The flowchart shows an algorithm used for quality control on a biscuit production line.
The weight of each biscuit is entered into the variable Weight. If the weight of the biscuit is
between 16.2 and 17.2 grammes, inclusive, the pass counter is incremented by 1. Otherwise,
the reject counter is incremented by 1. The process continues until –1 is entered, after which, the
totals for pass and reject counters are output.
(a) Complete this flowchart.
START
PassCount
0
RejectCount
0
Yes
No
No
Yes
STOP
[6]
ĬÍĊ®Ġ´íÈõÏĪÅĊÝü·þ×
,
,
(b) Explain how you would alter the flowchart in 1(a) so that it calculates and outputs the average
weight of only the biscuits that passed the weight check.
You may include program statements or flowchart symbols in your answer, but they must be
fully explained.
…
…
…
…
…
…
…
…
…
… [4]
Question text
5
(a) A computer store uses a database table COMPONENT to store the stock details of a range of
components needed to build computer systems.
Complete the table by giving appropriate data types for each field.
Only the data types: text, character, Boolean, integer, real, date/time are available in this
database.
Field
Data type
Description
ID
unique identifier
Name
component name
Description
component description
selling price of component to
Price
2 decimal places
NumberAvailable
number in stock
level at which the component
MinimumLevel
is reordered
whether or not the component
ReOrdered
has been reordered
the date the component was
DateOrdered
reordered
[4]
(b) Complete the structured query language (SQL) statement to list only the unique identifier,
component name and reorder date of all the components that have been reordered.
SELECT …
FROM …
WHERE … ;
[4]
ĬÓĊ®Ġ´íÈõÏĪÅĊÞü¶þ×
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]
ĬÓĊ®Ġ´íÈõÏĪÅĊÞûµĀ×
Question text
10 A shop that sells cheese has set up a new database table called CheeseStock to store details of
the cheeses available for sale. Part of this table is given.
ChNo
Name
InStock
SupplierCode
PricePerKg
WeightKg
CH01
American
Yes
XYZ
4.50
20.0
CH02
Brie
Yes
XYZ
7.50
21.0
CH03
Burrata
No
IMP
13.75
0.0
CH04
Camembert
No
ABC
16.85
0.0
CH05
Cheddar
Yes
ABC
5.00
50.0
CH06
Comté
No
SPC
7.35
0.0
CH07
Cottage
Yes
XYZ
4.50
3.0
CH08
Cream
Yes
XYZ
5.50
6.5
CH12
Emmental
Yes
IMP
2.75
1.5
CH15
Feta
Yes
IMP
12.75
12.0
CH16
Fontina
Yes
SPC
15.99
1.2
CH17
Gorgonzola
Yes
SPC
15.25
0.3
CH19
Gouda
Yes
SPC
7.99
2.5
CH21
Gruyère
No
SPC
16.75
0.0
CH22
Halloumi
Yes
IMP
4.75
15.0
CH23
Havarti
No
SPC
6.75
0.0
CH27
Manchego
No
IMP
13.99
0.0
CH30
Manouri
No
IMP
18.50
0.0
CH31
Mascarpone
No
SPC
12.99
0.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) Write the output from this structured query language (SQL) statement.
SELECT ChNo, WeightKg
FROM CheeseStock
WHERE SupplierCode = 'ABC';
…
…
… [2]
(d) (i)
Complete this SQL statement to display only the name of all the cheeses that are out of
stock.
SELECT …
FROM …
WHERE … ;
[3]
(ii)
Explain how one of the lines in your statement in part (d)(i) could be changed to display
the same information.
…
…
…
… [2]
ĬÓĊ®Ġ´íÈõÏĪÅĊßú·þ×
Question text
11
A database table called Booking28 stores details of hotel rooms and bookings for the week
beginning Monday 7 July 2025.
RoomNo
Type
Guests
Rate$
Mon
Tue
Wed
Thu
Fri
Sat
Sun
101D
Double
2
99.99
T
T
T
T
F
T
T
102D
Double
2
99.99
T
T
T
F
T
T
T
103F
Family
4
150.00
T
T
T
T
T
T
T
104S
Single
1
72.50
F
T
T
F
T
T
T
105S
Single
1
72.50
F
T
T
F
T
T
T
106T
Twin
2
120.00
T
T
T
T
F
T
T
201F
Family
4
160.00
F
F
T
T
T
T
T
202D
Double
2
120.00
T
F
T
T
T
T
T
203T
Twin
2
120.00
T
F
T
T
T
T
T
204T
Twin
2
125.00
T
F
T
F
T
T
T
205S
Single
1
79.99
T
F
T
T
F
T
T
301D
Double
2
200.00
F
T
T
F
F
T
T
302T
Twin
2
200.00
T
T
T
T
F
T
T
303P
Suite
4
500.00
T
T
T
T
F
T
T
304P
Suite
6
700.00
F
F
F
F
T
T
T
(a) State the number of fields and records in this database table.
Fields …
Records …
[2]
(b) State the reason why the Type field would not be suitable as a primary key.
…
… [1]
ĬÑĊ®Ġ´íÈõÏĪÅĊÝû¸þ×
,
,
(c) The database uses only the data types:
•
alphanumeric
•
character
•
Boolean
•
integer
•
real
•
date/time.
Complete the table to show the fields that could have the given data types.
Only one field name is required in each box and each field name must be different.
Field
Data type
alphanumeric
Boolean
real
integer
[2]
(d) Give the output that would be produced by the structured query language (SQL) statement:
SELECT RoomNo, Type, Guests, Rate$
FROM Booking28
WHERE Mon <> T;
…
…
…
…
…
… [3]
ĬÓĊ®Ġ´íÈõÏĪÅĊÝù¸þ×
Question text
4
Complete the paragraph about databases. Use terms from the list. You may need to use a term
more than once. Some of the terms in the list will not be used.
fields
comments
columns
constant
key
table
primary key
program
records
rows
scripts
database
validation
variable
Database tables consist of … and … .
Rows are … .
… are fields.
Structured query language (SQL) … are used to query data.
A … uniquely identifies a record.
[6]
Question text
11
Building materials are sold in bags. A new database table called BuildStock has been set up to
store details about the materials for sale. Part of this table is given.
MtNo
Name
InStock
WeightKg
PricePerBag
NumberBags
MT01
Builders sand
Yes
50
4.50
50
MT02
Sharp sand
Yes
25
3.50
21
MT03
Red sand
No
50
2.75
0
MT04
Cement
No
25
6.85
0
MT05
Chippings
Yes
50
35.00
50
MT06
Cobbles
No
75
67.35
0
MT07
Pebbles small
Yes
50
34.50
3
MT08
Pebbles medium
Yes
25
25.50
10
MT12
Pebbles large
Yes
75
62.75
20
MT15
Washed gravel
Yes
50
12.75
12
MT16
Pea gravel
Yes
100
15.95
24
(a) Write the output from this structured query language (SQL) statement.
SELECT MtNo, Name
FROM BuildStock
WHERE WeightKg = 75
ORDER BY PricePerBag;
…
…
… [3]
(b) (i)
Complete this SQL statement to display only the names of all the materials that are out
of stock.
SELECT …
FROM …
WHERE …
[2]
(ii)
Explain how another SQL statement using a different field could be used to display the
same information.
…
…
…
… [2]
ĬÑĊ®Ġ´íÈõÏĪÅĊàù·þ×
Question text
6
The flowchart represents an algorithm.
START
Result
Limit DIV 2 + 1
INPUT
Limit
OUTPUT
Numbers[Result]
Count
1
INPUT
Numbers[Count]
STOP
Count
Count + 1
No
IS Count >
Limit?
No
IS Numbers[Count] >
Yes
Numbers[Count + 1]?
Flag
TRUE
Yes
Swap
Numbers[Count]
IS Flag =
No
TRUE?
Numbers[Count]
Numbers[Count + 1]
Yes
Flag
False
Numbers[Count + 1]
Swap
Count
1
Flag
True
IS Count >
Yes
No
Limit – 1?
Count
Count + 1
(a) Complete the trace table for the input data:
7, 47, 50, 52, 60, 80, 63, 70
Numbers
Limit
Count
[1]
[2]
[3]
[4]
[5]
[6]
[7]
Flag
Swap
Result
OUTPUT
[7]
(b) Outline the processes involved in the algorithm shown in the flowchart on page 6.
…
…
…
…
…
… [3]
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
5
The flowchart represents an algorithm.
START
L
0
S
10000
T
0
A
0
INPUT
Limit
Count
1
INPUT
Value
IS
IS
No
No
Value < S
Value > L
?
?
Yes
Yes
L
Value
S
Value
T
T + Value
IS
No
Count >
Count
Count + 1
Limit ?
Yes
T / Limit
A
OUTPUT "L = ", L, " S = ",
S, " T = ", T, " A = ", A
STOP
(a) Complete the trace table for the input data:
10, 30, 18, 8, 25, 12, 17, 2, 50, 15, 5
L
S
T
A
Limit
Count
Value
OUTPUT
[6]
(b) Outline the purpose of the algorithm.
…
…
…
… [2]
(c) Explain why the identifiers L, S, T and A may not be appropriate to use as identifiers and how
they could be improved.
…
…
…
…
…
… [3]
(d) State a more appropriate identifier for each of the variables L, S, T and A
Original identifier
Improved identifier
L
S
T
A
[2]
Question text
A database table called Hangar1 stores details of a collection of historic aircraft at a museum.
8
ID
Make
Model
Year
Engines
Airworthy
JM1
Hawker Siddeley
Nimrod
1966
4
Y
JM2
Douglas
DC-10
1970
3
Y
JM3
Aérospatiale-BAC
Concorde
1973
4
N
PB1
De Havilland
DH-9
1918
1
Y
PB2
Hawker
Fury
1935
1
Y
PB3
Hawker
Nimrod
1934
1
Y
PM1
Fieseler
Storch
1942
1
N
PM2
Hawker
Hurricane
1942
1
Y
PM3
Supermarine
Spitfire
1942
1
N
PM4
Douglas
C-47 Dakota
1942
2
N
PS1
Boeing
314 Clipper
1936
4
N
(a) State the number of fields and records in the database table.
Fields …
Records …
[2]
(b) Give the output that would be produced by the structured query language (SQL) statement:
SELECT Model, Year, Engines
FROM Hangar1
WHERE Engines > 1
ORDER BY Year;
…
…
…
…
…
…
…
… [4]
(c) Complete the SQL statement to display only the ID and model of all the aircraft that are
airworthy.
SELECT ID, …
…
…
… ;
[4]
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]
Question text
9
A model shop wants to set up a database to help with stock control of the model figures available
for sale. The shop wants to store this information about the model figures:
Field 1 – catalogue number, for example MD1234
Field 2 – description, for example ‘small white dog’
Field 3 – number in stock, for example 5
Field 4 – the price of each model, for example 7.40
Field 5 – if the model has already been painted, yes or no.
(a) The shop needs five fields for each record.
Give a suitable name and data type for each field.
Field 1 name …
Data type …
Field 2 name …
Data type …
Field 3 name …
Data type …
Field 4 name …
Data type …
Field 5 name …
Data type …
[5]
(b) (i)
Give the name of the field that should be used for the primary key.
… [1]
(ii)
State why this field is used as the primary key.
… [1]
(c) Structured query language (SQL) is used to query data stored in this database.
State what these SQL commands are used for.
SELECT …
…
FROM …
…
WHERE …
…
[3]