Databases and SQL – IGCSE Computer Science (0478)

116 questions · page 5 of 8 · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
61
0478/23/O/N/20 · Question 2Oct/Nov 2020Paper 2312 marks
Loading question…
Question text

2
An algorithm has been written in pseudocode to check the temperature readings taken from a
freezer are within the range –18 degrees to –25 degrees inclusive.
The algorithm counts the number of times that the temperature reading is below –25 degrees and
the number of times that the temperature reading is above –18 degrees.
An engineer is called if there are more than 10 temperature readings below –25 degrees.
An alarm sounds if there are more than 5 temperature readings above –18 degrees.
0
01
TooHot
1000
02
TooCold
03
REPEAT
04
OUTPUT "Please enter temperature"
05
INPUT Temperature
06
IF Temperature < -25
07
THEN
TooCold – 1
08
TooCold
09
ENDIF
10
IF Temperature > -18
11
THEN
TooHot + 1
12
TooHot
13
ENDIF
14
UNTIL TooHot > 5 OR TooCold > 10
15
IF TooHot < 5
16
THEN
17
INPUT "Alarm!!"
18
ENDIF
19
IF TooCold > 10
20
THEN
21
OUTPUT "Call the Engineer"
22
ENDIF
(a) Give the line number(s) from the algorithm of:
an assignment statement …
a loop …
a counting statement …
a selection statement …
[4]
(b) Give line numbers where the four errors are to be found in the pseudocode. Suggest a
correction for each error.
Error 1 line number …
Correction …
…
Error 2 line number …
Correction …
…
Error 3 line number …
Correction …
…
Error 4 line number …
Correction …
…
[4]
(c) Explain how you could extend the algorithm to count the number of times the temperature
readings are within the range –18 degrees to –25 degrees inclusive.
…
…
…
…

62
0478/23/O/N/20 · Question 5Oct/Nov 2020Paper 238 marks
Loading question…
Question text

5
A marine wildlife rescue centre uses a database table, MARINE, to keep records of its creatures.
Creature
Class
Quantity
Ready for release
Offspring
Manta Ray
Fish
3
Y
N
Short-tailed Albatross
Bird
4
Y
N
Emperor Penguin
Bird
50
Y
Y
Bluefin Tuna
Fish
2
N
N
Manatee
Mammal
4
Y
N
Hawksbill Turtle
Reptile
10
Y
Y
Hammerhead Shark
Fish
3
Y
N
Yellow-eyed Penguin
Bird
4
Y
N
Kemp’s Ridley Sea Turtle
Reptile
1
Y
N
(a) State how many fields and how many records are shown in this table.
Number of fields …
Number of records …
[2]
(b) Show the output that would be given by this query-by-example.
Field: Creature
Class
Ready for release
Table: MARINE
MARINE
MARINE
Sort:
Show:
3
3
Criteria:
="Bird"
or:
…
…
… [2]
(c) Complete the query-by-example grid to display the creatures, in ascending order of quantity,
that have no offspring and are ready for release. Display only the creature field.
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

63
0478/21/M/J/20 · Question 4May/June 2020Paper 218 marks
Loading question…
Question text

4
The pseudocode algorithm shown should allow numbers to be entered and should allow
50 numbers to be stored in an array.
←
0
Count
REPEAT
INPUT Values[Count]
←
Count + 1
Count
UNTIL Count = 0
(a) Explain why the algorithm will never end.
…
…
…
…
… [2]
(b) Re-write the original pseudocode so that it terminates correctly and also prevents numbers
below 100 from being stored in the array Values[ ]
…
…
…
…
…
…
…
…
…
… [4]
(c) Describe how you could change your pseudocode in part (b) so that it prevents numbers
below 100 and above 200 from being stored in the array Values[ ]
…
…
…
… [2]

Advertisement
64
0478/21/M/J/20 · Question 6May/June 2020Paper 217 marks
Loading question…
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

65
0478/22/M/J/20 · Question 18May/June 2020Paper 2225 marks
Loading question…
Question text

18
OUTPUT "There are ", HighestMarkStudents," with the highest mark of ",
HighestMark
Give line numbers where the four errors are to be found in the pseudocode. Suggest a
correction for each error.
Error 1 line number …
Correction …
…
Error 2 line number …
Correction …
…
Error 3 line number …
Correction …
…
Error 4 line number …
Correction …
…
[4]
(b) Explain how you could extend the algorithm to also find the lowest mark awarded, count the
number of students with that mark, and output both these values.
…
…
…
…
…
…
…
…
…
…
…
…
…

66
0478/23/M/J/20 · Question 7May/June 2020Paper 237 marks
Loading question…
Question text

7
A convenience store which sells general groceries wants to set up a database table called
STOCK. The table will contain fields including a description of the item, the price of the item
and the number in stock for each item. The STOCK table also has a fourth field to be used as a
primary key.
(a) Complete the table to suggest a suitable field name for each of the four fields in the table
STOCK. Give the purpose of the data to be stored in each field.
Field name
Purpose of field contents
[4]
(b) Complete the query-by-example grid to output stock items where the quantity in stock has
fallen below 20. Only show the primary key and description of the items.
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

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

68
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
69
0478/21/O/N/19 · Question 4Oct/Nov 2019Paper 2135 marks
Loading question…
Question text

4
(a) Complete the trace table for this algorithm using the given input data.
0
Index
0 TO 7
FOR Count
INPUT Value
IF Value > 50
THEN
Value
PassMarks[Index]
Index + 1
Index
ENDIF
NEXT Count
PRINT "Number passed ", Index
Input data: 58, 40, 67, 85, 12, 13, 75, 82
PassMarks
OUTPUT
Index Count Value [0] [1] [2] [3] [4] [5] [6] [7]
[6]
(b) Give the purpose of the algorithm shown in part (a).
…
…
… [1]

70
0478/21/O/N/19 · Question 5Oct/Nov 2019Paper 218 marks
Loading question…
Question text

5
A car manufacturer makes a range of car models named Pegasus, Apollo and Cupid. It keeps a
database to store the records of its range and the different options for each car model. Within the
table CAR_RANGE, the following data needs to be stored:
1.
Car model
2.
Body style – saloon, hatchback or estate
3.
How many doors it has
4.
Whether it uses petrol, diesel or batteries as fuel
5.
An identifier for a specific car.
(a) Complete the table to show suitable field names and an example of appropriate data for each
field in the database table CAR_RANGE.
Field name
Example of data
[3]
(b) State which of your fields would be most appropriate for a primary key and give a reason for
your choice.
…
…
… [2]
(c) Complete the query-by-example grid to provide a list of car models using petrol and the
number of doors these cars have, in alphabetical order of car model. Display only the car
models and the number of doors.
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

71
0478/22/O/N/19 · Question 3Oct/Nov 2019Paper 227 marks
Loading question…
Question text

3
(a) The flowchart checks the lengths of a batch of 10 ropes. For the batch to be accepted 90% of
the lengths need to be between 24.9 and 25.1 metres.
START
Reject
0
Count
0
Yes
Is Count =
10 ?
No
No
Is Reject
Count
Count + 1
<= 1 ?
INPUT Length
Yes
OUTPUT "Batch
rejected"
Is Length <
Yes
25.1 AND
Length > 24.9 ?
No
Reject
Reject + 1
OUTPUT "Batch
accepted"
END
Complete the trace table for the input data:
24.88, 25.01, 24.98, 25.00, 25.05, 24.99, 24.97, 25.04, 25.19, 25.07
Reject
Count
Length
OUTPUT
[4]
(b) (i)
It has been decided to only reject batches of rope that contain ropes that are too short.
State the change required to the algorithm.
…
… [1]
(ii)
Explain how the algorithm to reject batches could be improved to make it more effective.
…
…
…
… [2]

72
0478/22/O/N/19 · Question 7Oct/Nov 2019Paper 226 marks
Loading question…
Question text

7
A database table, SALES, is used to keep a record of items made and sold by a furniture maker.
Item number
Order number
Notes
Amount
Status
CH001
1921
Smith – six dining chairs
6
Delivered
TB003
1921
Smith – large table
1
In progress
CH001
1924
Hue – extra chairs
4
In progress
CH003
1925
For stock
2
Cancelled
BN001
1927
Patel – replacement bench
1
Not started
ST002
1931
Sola – small table
1
Delivered
CH003
1927
Patel – eight dining chairs with arms
8
Not started
TB003
1927
Patel – large table
1
Not started
(a) Explain why the field Item number could not be used as a primary key.
…
… [1]
(b) A query-by-example has been written to display only the order number and item numbers of
any items in progress or not started.
Field:
Item number
Order number
Amount
Status
Table:
SALES
SALES
SALES
SALES
Sort:
Show:
3
3
Criteria:
Not Like "Delivered"
or:
Explain why the query-by-example is incorrect, and write a correct query-by-example.
Explanation …
…
…
…
…
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

73
0478/23/O/N/19 · Question 7Oct/Nov 2019Paper 238 marks
Loading question…
Question text

7
A teacher has decided to use a database table as her mark book for her Computer Science class,
which she has called MARKBOOK. For each student, the following data will be recorded: first
name, last name, their year 10 test score and their year 11 test score. The class has 32 students.
(a) State the number of fields and records required for this database.
Number of Fields …
Number of Records …
[2]
(b) The data in MARKBOOK is stored under category headings: LastName, FirstName,
Y10TestScore and Y11TestScore.
State, with a reason, whether any of these headings would be suitable as a primary key.
…
…
…
… [2]
(c) Complete the query-by-example grid to only display the first name, last name and year 10
test score of each student who achieved 50 or more in their year 10 test. The output should
be in test score order with the highest marks at the top of the list.
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
74
0478/21/M/J/19 · Question 5May/June 2019Paper 219 marks
Loading question…
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

75
0478/22/M/J/19 · Question 2May/June 2019Paper 228 marks
Loading question…
Question text

2
(a) An algorithm has been written in pseudocode to input 100 numbers, select and print the
largest number and smallest number.
1
Count
INPUT Number
Number
High
Count
Low
REPEAT
INPUT Number
IF Number > High
THEN
Number
High
ENDIF
IF Number > Low
THEN
Number
Low
ENDIF
Count + 1
Count
UNTIL Count > 99
PRINT "Largest Number is ", Number
PRINT "Smallest Number is ", Low
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 total the numbers and print the total.
Use a variable Total.
…
…
…
…
…
…
…
… [4]

Advertisement