Databases and SQL – IGCSE Computer Science (0478)

116 questions · page 4 of 8 · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
46
0478/23/M/J/22 · Question 6May/June 2022Paper 234 marks
Loading question…
Question text

6
Data about planets in the solar system is stored in a database table called PLANETS. The fields
used in the table are shown.
Name of field
Contents of field
PlanetName
the name of the planet
PlanetMass
the planet’s mass in kilograms
whether or not the planet has a greater mass than Earth
Larger
MaxDistance
the maximum distance the planet is from Earth in kilometres
MinDistance
the minimum distance the planet is from Earth in kilometres
YearLength
the length of time it takes for the planet to orbit the Sun in Earth days
(a) State the name of the field that could contain Boolean data.
… [1]
(b) Complete the query-by-example grid to output the planets with a longer year length and
greater mass than Earth. Assume Earth’s year length is 365 days.
Display only the name of the planets sorted in alphabetical order.
Field:
Table:
Sort:
o
o
o
o
o
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

47
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]

48
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

Advertisement
49
0478/21/O/N/21 · Question 4Oct/Nov 2021Paper 215 marks
Loading question…
Question text

4
The algorithm shown by this flowchart allows the input of examination marks for a class of students.
A mark of –1 ends the process. If a mark is 80 or over then a distinction grade is awarded. The
number of distinctions for the whole class is calculated. If this is over 50% of the class, the class is
awarded a highly commended certificate.
START
← 0
← 0
Counter
Distinction
INPUT
Mark
← Distinction/Counter
Yes
IS
Award
Mark = –1?
No
← Counter + 1
Yes
OUTPUT
IS
Counter
"Highly
Award > 0.5?
Commended"
No
← Distinction + 1
Distinction
END
IS
Yes
Mark >= 80?
No
Complete a trace table for the algorithm using this input data:
88, 74, 60, 90, 84, 87, 95, 72, 84, 66, –1
Counter
Distinction
Mark
Award
OUTPUT
[5]

50
0478/21/O/N/21 · Question 5Oct/Nov 2021Paper 217 marks
Loading question…
Question text

5
A database table, APPLIANCE, is used to keep a record of kitchen appliances available for sale.
The following data is stored for each appliance:
•
CATEGORY – washer, dishwasher, fridge or freezer
•
ECONOMYRATING – A, B, C or D
•
MANUFACTURER – Baku or ABC
•
PRICE – price in $
•
CODE – a unique code allocated by the manufacturer e.g. B982
•
STOCK – number in stock.
The database management system uses these data types:
Text
Number
Currency
Boolean
The ECONOMYRATING field and MANUFACTURER field have a data type of text.
(a) Identify the most appropriate data type for each field from the four types shown. State the
reason why you chose each data type.
CATEGORY data type …
Reason …
…
PRICE data type …
Reason …
…
CODE data type …
Reason …
…
STOCK data type …
Reason …
…
[4]
(b) Complete the query-by-example grid to display only the category, manufacturer and code of
the appliances with an economy rating of A.
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

51
0478/22/O/N/21 · Question 6Oct/Nov 2021Paper 226 marks
Loading question…
Question text

6
A pet supplier uses the database table, STOCK, to keep records of its products for pets.
The fields are:
Field name
Description
ProductID
code to identify the product
ProductName
name of product
ProductDescription
information about the product
Animal
type of animal the product is for, e.g. cat, bird, horse
ProductType
type of product, e.g. food, toy, medicine
whether the product is in stock or not
InStock
(a) (i)
Identify the field that could have a Boolean data type.
… [1]
(ii)
Identify the field that should be used as the primary key.
… [1]
(b) Complete the query-by-example grid to output the products intended for a cat that are in
stock. Display only the primary key and the name of the products. The output should be
sorted by the primary key.
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

52
0478/23/O/N/21 · Question 4Oct/Nov 2021Paper 235 marks
Loading question…
Question text

4
The algorithm, shown by this flowchart, allows the input of examination marks for a class of
students. A mark of 999 ends the process. If a mark is 40 or over then a pass grade is awarded.
The number of pass grades is calculated for the whole class. If this is under 50% of the class, the
class is offered extra help.
START
Counter
0
Pass
0
INPUT
Mark
IS
Yes
Mark = 999 ?
Help
Pass / Counter
No
IS
Yes
OUTPUT
Counter
Counter + 1
Help < 0.5 ?
"Extra Help"
No
IS
Yes
Mark >= 40 ?
Pass
Pass + 1
END
No
Complete a trace table for the algorithm using this input data:
88, 24, 60, 30, 44, 17, 25, 22, 54, 6, 999, −1
Counter
Pass
Mark
Help
OUTPUT
[5]

53
0478/23/O/N/21 · Question 5Oct/Nov 2021Paper 237 marks
Loading question…
Question text

5
A database table, COMPUTER, is used to keep a record of computers available for sale.
The following data is stored for each computer:
•
CATEGORY – desktop, laptop or tablet
•
WEIGHT – weight in kilograms
•
MANUFACTURER – ICN, Linoldo, Pear or JoeSing
•
PRICE – price in $
•
CODE – a unique code allocated by the manufacturer, e.g. P771
•
STOCK – quantity in stock.
A database management system uses these data types:
Text
Number
Currency
Boolean
The CATEGORY field and MANUFACTURER field have a data type of text.
(a) Select the most appropriate data type for each field from the four types shown. State the
reason why you chose the data type.
WEIGHT data type …
Reason …
…
PRICE data type …
Reason …
…
CODE data type …
Reason …
…
STOCK data type …
Reason …
…
[4]
(b) Complete the query-by-example grid to display only the category, manufacturer, price and
code of the computers with weight of less than 2.5 kilograms.
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

Advertisement
54
0478/21/M/J/21 · Question 6May/June 2021Paper 216 marks
Loading question…
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

55
0478/22/M/J/21 · Question 6May/June 2021Paper 225 marks
Loading question…
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

56
0478/23/M/J/21 · Question 4May/June 2021Paper 238 marks
Loading question…
Question text

4
The pseudocode algorithm should allow a user to input the number of scores to be entered and
then enter the scores. The scores are totalled, the total is output and the option to enter another
set of scores is offered.
←
0
1 Count
2 REPEAT
←
20
3
FullScore
4
INPUT Number
←
1 TO Number
5
FOR StoreLoop
6
INPUT Score
←
FullScore
7
FullScore
8
UNTIL StoreLoop = Number
9
OUTPUT "The full score is ", FullScore
10
OUTPUT "Another set of scores (Y or N)?"
11
OUTPUT Another
12
IF Another = "N"
13
THEN
←
1
14
Count
15
ENDIF
16 UNTIL Count = 1
(a) Identify 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 could change the algorithm to store the individual scores in the array
ScoreArray[], then find and print the average score once the scores have all been entered.
…
…
…
…
…
…
…
…
…
…

57
0478/23/M/J/21 · Question 6May/June 2021Paper 236 marks
Loading question…
Question text

6
A car hire company uses a database table, TREAD, to store details of the cars. The table has
fields to represent each car’s licence number, mileage, and the tread depth of each of its four
tyres.
(a) Suggest suitable names for each of the fields described.
Field name
[2]
(b) Complete the query-by-example grid to display cars where all four tyres have a tread depth
of less than 2. Display all the fields, using the field names you created in part (a). The output
should be sorted by licence number.
Field:
Table:
Sort:
Show:
o
o
o
o
o
o
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

58
0478/21/O/N/20 · Question 5Oct/Nov 2020Paper 218 marks
Loading question…
Question text

5
A database table, AIRLINE, stores data used to compare airlines.
Number of
Number of
Head office
Share price
Code
Airline name
employees
countries
FJ
FastJet
60000
30
Europe
514.50
MA
MurphyAir
35000
8
Europe
152.67
JS
JetSeven
45000
22
Asia
257.44
K3
Koala3
22000
11
Australia
501.21
NS
NorthState
30000
4
America
108.22
SS
SouthState
30000
4
America
126.35
BJ
BlueJet
15000
7
Africa
215.45
SK
SkyKing
32000
27
Europe
506.12
PF
PandaFly
50000
35
Asia
317.88
(a) State how many fields and how many records are shown in the AIRLINE table.
Number of Fields …
Number of Records …
[2]
(b) Show the output that would be given by this query-by-example.
Field: Airline name
Number of employees
Head office
Share price
Table: AIRLINE
AIRLINE
AIRLINE
AIRLINE
Sort:
Show:
3
3
Criteria:
< 35000
> 500.00
or:
…
…
… [2]
(c) Complete the query-by-example grid to find every airline with a head office in Asia or Africa,
and number of countries greater than 4. Only show the airline name and number of countries.
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

Advertisement
59
0478/22/O/N/20 · Question 4Oct/Nov 2020Paper 226 marks
Loading question…
Question text

4
This pseudocode algorithm allows 5000 numbers to be entered and stored in an array called
Number.
1 TO 5000
FOR Count
INPUT Number[Count]
NEXT Count
Extend and re-write the algorithm using pseudocode to also count and output how many of the
numbers stored in the array are greater than 500, using the variable Higher. Only output Higher
once with an appropriate message.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]

60
0478/22/O/N/20 · Question 7Oct/Nov 2020Paper 227 marks
Loading question…
Question text

7
The table AUDIOPARTS stores the part number, description, cost and quantity in stock of the
items sold by a music shop.
PartNum
Description
Cost
Quantity
A01
Compact Amplifier Case
50.00
15
A02
Deluxe Amplifier Case
75.00
1
A03
Amplifier Standard
79.99
48
A04
Amplifier Midrange
149.99
50
A05
Amplifier Megablaster
299.99
48
S01
Tweeter
59.99
10
S02
Midrange Woofer
99.99
0
S03
Subwoofer
139.99
16
S04
Tower Speaker Basic
159.99
25
S05
Tower Speaker Skyscraper
219.99
9
S06
Centre Speaker
149.99
25
S07
Soundbar
89.99
2
S20
Soundbar
129.99
0
S21
Ceiling Surround Speaker
75.00
15
S22
Ceiling Full Range Speaker
100.00
1
S25
Surround Speaker
100.00
60
T19
Speaker Stands (Pair)
75.00
60
(a) State the number of records in the table AUDIOPARTS
… [1]
(b) Identify the field that is most suitable to be a primary key and give a reason for your choice.
Fieldname …
Reason …
…
…
[2]
(c) Complete the query-by-example grid to show the items where the quantity in stock is fewer
than 10. Show all the fields from the database table in descending order of cost.
Field:
Table:
Sort:
Show:
Criteria:
or:
[4]

Advertisement