Databases and SQL – IGCSE Computer Science (0478)
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
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
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]
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]
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.
…
…
…
…
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
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]
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
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.
…
…
…
…
…
…
…
…
…
…
…
…
…
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
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]
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
Question text
3
The data from a sensor must be converted from analogue to digital to be processed by a computer.
(a) State what is meant by analogue data.
…
… [1]
(b) State what is meant by digital data.
…
… [1]
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]
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