Databases and SQL – IGCSE Computer Science (0478)
Question text
4
A programmer wants to test that the readings from 2000 electricity meters are greater than 400
units and less than 900 units. The programmer uses selection and repetition statements as part of
the program.
Explain, using programming statements, how selection and repetition could be used in this
program.
Selection …
…
…
…
…
Repetition …
…
…
…
…
…
…
…
[4]
Question text
6
A database table, PORTRAIT, is used to keep a record of the portraits available from a photographic
studio. Each portrait has a unique reference number PICnnn, where n is a single digit, for example
PIC123. The studio keeps a record of the size (for example 20 × 15), the type (black and white or
colour), and the price in dollars.
(a) Complete the table to show the most appropriate data type for each of the fields.
Field
Data type
Reference Number
Size
Type
Price in $
[4]
(b) The results from the query-by-example grid should show the reference number, price, type
and size of all portraits under $50. Identify the three errors in the query-by-example grid.
Field:
Reference No
Price in $
Type
Size
Table:
PORTRAIT
PORTRAIT
PORTRAIT
PORTRAIT
Sort:
Show:
Criteria:
>50.00
or:
Error 1 …
…
Error 2 …
…
Error 3 …
…
[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
Question text
4
This is a section of program code.
1 Total = 100.00
2 PRINT ′Enter the height of each member of your class, one at a
time, when prompted′
3 FOR Count = 1 TO 30
4
PRINT ′Enter a height in metres′
5
INPUT Height
6
Total = Total + Height
7
PRINT Total / 30
8
Count = Count + 1
9 NEXT Count
(a) There are three errors in this code.
State the line numbers that contain the errors and describe how to correct each error.
Error 1 …
…
…
Error 2 …
…
…
Error 3 …
…
…
[3]
(b) State the purpose of this program.
…
…
… [1]
Question text
6
An online fruit tree specialist sells fruit trees in various sizes. A database table, TREETAB, shows
the tree type and, for each size, the price and whether they are in stock.
Tree Type
Size1
Size1 In
Size2
Size2 In
Size3
Size3 In
Apple
10.95
Yes
14.95
Yes
29.95
Yes
Apple
12.95
Yes
14.95
Yes
29.95
Yes
Cherry
24.95
No
34.95
No
59.95
Yes
Fig
19.95
Yes
29.95
No
49.95
Yes
Guava
19.95
No
29.95
No
59.95
No
Nectarine
8.50
Yes
11.95
Yes
19.95
Yes
Olive
19.95
No
39.95
Yes
59.95
Yes
Peach
9.25
No
11.95
Yes
19.95
Yes
Pear
10.95
Yes
14.95
Yes
29.95
Yes
Plum
8.95
Yes
11.95
Yes
19.95
Yes
Pomegranate
12.95
No
18.95
Yes
34.95
No
Quince
34.95
Yes
44.95
Yes
84.95
No
(a) State whether any of the fields shown would be suitable as a primary key.
…
Explain your answer …
…
…
[2]
(b) Complete the table to show the most appropriate data type for each of the fields based on the
data shown in the table at the start of question 6.
Field
Data type
Tree Type
Size3
Size2 In
[3]
(c) Show the output that would be given by this query-by-example.
Field: Tree Type
Size1
Size1 In
Table: TREETAB
TREETAB
TREETAB
Sort:
Descending
Show:
Criteria:
<10.00
or:
…
…
…
… [4]
(d) Using the following query-by-example grid, write a query to identify all types of the fruit trees
that are out of stock for all three sizes. Make sure the type of the tree and the various ‘in
stock’ fields are shown. The trees should be listed in alphabetical order by 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
Question text
6
A database table, PERFORMANCE, is used to keep a record of the performances at a local
theatre.
Show Number
Type
Title
Date
Sold Out
SN091
Comedy
An Evening at Home
01 Sept
Yes
SN102
Drama
Old Places
02 Oct
No
SN113
Jazz
Acoustic Evening
03 Nov
No
SN124
Classical
Mozart Evening
04 Dec
Yes
SN021
Classical
Bach Favourites
01 Feb
Yes
SN032
Jazz
30 Years of Jazz
02 Mar
Yes
SN043
Comedy
Street Night
03 Apr
No
SN054
Comedy
Hoot
04 May
No
(a) State the number of fields and records in the table.
Fields …
Records …
[2]
(b) Give two validation checks that could be performed on the Show Number field.
Validation check 1 …
…
Validation check 2 …
…
[2]
(c) Using the query-by-example grid, write a query to identify jazz performances that are not sold
out. Only display the date and the title.
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
Question text
2
(a) Draw a flowchart for an algorithm to input numbers. Reject any numbers that are negative
and count how many numbers are positive. When the number zero is input, the process ends
and the count of positive numbers is output.
[6]
(b) Explain the changes you will make to your algorithm to also count the negative numbers.
…
…
…
… [2]
Question 3 starts on Page 8.
Question text
5
A program checks that the weight of a basket of fruit is over 1.00 kilograms and under
1.10 kilograms. Weights are recorded to an accuracy of two decimal places and any weight not in
this form has already been rejected.
Give three weights as test data and for each weight state a reason for choosing it. All your reasons
must be different.
Weight 1 …
Reason …
…
Weight 2 …
Reason …
…
Weight 3 …
Reason …
…
[3]
Question text
6
A database table, TREES, is used to keep a record of the trees in a park. Each tree is given a
unique number and is examined to see if it is at risk of dying. There are over 900 trees; part of the
database table is shown.
Tree Number
Type
Map Position
Age in Years
At Risk
TN091
Acacia
A7
250
Y
TN172
Olive
C5
110
N
TN913
Cedar
B9
8
N
TN824
Banyan
A3
50
Y
TN021
Pine
D5
560
Y
TN532
Teak
C8
76
Y
TN043
Yew
B1
340
N
TN354
Spruce
D4
65
N
TN731
Elm
B10
22
Y
TN869
Oak
C9
13
N
TN954
Pine
E11
3
N
(a) State the number of fields in the table.
… [1]
(b) The tree numbering system uses TN followed by three digits. The numbering system will not
work if there are over 1000 trees.
Describe, with the aid of an example, how you could change the tree numbering system to
allow for over 1000 trees. Existing tree numbers must not be changed.
…
…
…
… [2]
(c) Using the query-by-example grid, write a query to identify at risk trees over 100 years old.
Display only the type and the position on the map.
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
Question text
3
This section of program code reads the contents of the array, totals the numbers and prints out the
sum and average of the numbers. Assume the array is full.
Complete the four missing items by writing them in the spaces provided in this code.
1
Numbers[1:30]
2
Total = 0
… = 0
3
FOR Count = 1 TO …
4
5
Number = Numbers[Count]
Total = … + Number
6
7
Counter = Counter + 1
… Count
8
9
PRINT ′The sum of the numbers you entered is ′, Number
10 PRINT ′The average of the numbers you entered is ′, Number / Counter
[4]
Question text
5
The flowchart allows a set of 10 numbers to be entered; it finds and outputs the largest of these
numbers.
START
Max
–1000.00
Counter
0
INPUT Num
Is Num >
Yes
Max ?
No
Max
Num
Counter
Counter + 1
Yes
Is Counter
< 10 ?
No
OUTPUT Max
END
(a) Complete the trace table for the input data:
6.30, 18.62, 50.01, 3.13, 2.05, 50.10, 40.35, 30.69, 0.85, 17.30
Max
Counter
Num
OUTPUT
[3]
(b) Describe two different changes you should make to the flowchart to find the smallest number
instead of the largest number.
Change 1 …
…
Change 2 …
…
[2]
Question text
6
A shop that sells copies of movies to the public has set up a new database table called 2018MOV
to store some new releases. Part of this table is given, showing the catalogue number, title, genres
and available formats (Blu-ray, DVD or streaming) of each movie.
CatNo
Title
Genre 1
Genre 2
Blu-ray
DVD
Stream
18m01
Battery Rangers
Adventure
Fantasy
Yes
No
Yes
18m02
Golfwatch
Comedy
Drama
Yes
No
Yes
18m03
Chair 27
Comedy
Drama
Yes
Yes
No
18m04
Wander Woman
Action
Fantasy
Yes
No
Yes
18m05
Justine League
Action
Fantasy
Yes
Yes
Yes
18m06
That
Horror
Thriller
Yes
Yes
No
18m07
Insect Dude
Action
Fantasy
No
Yes
No
18m08
Dover Beach
Action
History
No
Yes
No
18m12
Slow 25
Action
Thriller
No
Yes
No
18m15
Kongkers
Adventure
Fantasy
No
Yes
No
18m16
Transducers: The Last Night
Action
Sci-Fi
Yes
Yes
Yes
18m17
The Pale Tower
Fantasy
Sci-Fi
Yes
Yes
No
18m19
Bea and the Bute
Fantasy
Romance
Yes
Yes
Yes
18m21
The Daddy
Action
Fantasy
No
No
Yes
18m22
Planet Wars: Episode X
Sci-Fi
Action
Yes
No
Yes
18m23
Guardians of the Milky Way
Action
Sci-Fi
Yes
Yes
Yes
18m26
Odin
Horror
Sci-Fi
No
Yes
Yes
18m27
That
Fantasy
Sci-Fi
No
No
Yes
18m30
Underneath
Action
Horror
Yes
No
No
18m31
Debatable Me
Animation
Action
Yes
Yes
No
(a) State the number of records in this part of the table.
… [1]
(b) (i)
Give the name of the field that should 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 show the most appropriate data type for each field based on the data
shown in the table at the start of question 6.
Field
Data type
CatNo
Title
Genre 1
Stream
[2]
(d) List the output that would be given by this query-by-example.
Field:
CatNo
Title
Genre 1
Blu-ray
DVD
Stream
Table:
2018MOV
2018MOV
2018MOV
2018MOV
2018MOV
2018MOV
Sort:
Show:
3
3
3
3
3
Criteria:
=“Comedy”
or:
…
…
…
… [2]
(e)
Using the query-by-example grid, write a query to identify all the movies that are categorised
as Sci-Fi and available to stream. Only display the catalogue number and title of the film, with
the titles listed in alphabetical order.
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 Univers
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
Question text
6
A wildlife park has a database table, called LIVESTOCK, to classify and record its animal species.
Part of the database table is shown.
Species
Classification
Diet
Legs
Giraffe
Mammal
Herbivore
4
Elephant
Mammal
Herbivore
4
Crocodile
Reptile
Carnivore
4
Ostrich
Bird
Omnivore
2
Gorilla
Mammal
Herbivore
2
Bear
Mammal
Omnivore
4
Rhinoceros
Mammal
Herbivore
4
Hippopotamus
Mammal
Herbivore
4
Flamingo
Bird
Omnivore
2
Lion
Mammal
Carnivore
4
Turtle
Reptile
Omnivore
4
Penguin
Bird
Carnivore
2
(a) Suggest another appropriate field that could be added to this database by stating its name
and data type. State its purpose and give an example of the data it could contain.
Field name …
Data Type …
Purpose …
…
Example of data …
[2]
(b) Use the query-by-example grid below to provide a list of all four legged mammals that are
herbivores, sorted alphabetically by species, with only the species displayed.
Field:
Table:
Sort:
Show:
Criteria:
or:
[4]
Question text
5
(a) This flowchart checks a batch of 10 rice sacks for weight. Sacks should weigh 50 kilograms
each. Sacks weighing over 50.5 kilograms or less than 49.5 kilograms are rejected. The
number of sacks accepted and the number of sacks rejected is output.
START
Accept
0
Reject
0
Count
0
Yes
Is Count
= 10?
OUTPUT
Accept,
Accept
Accept + 1
No
Reject
Count
Count + 1
END
INPUT
Sack
Is Sack
Yes
Reject
Reject + 1
< 49.5?
No
Is Sack
> 50.5?
No
Yes
Complete the trace table for the input data:
50.4, 50.3, 49.1, 50.3, 50.0, 49.5, 50.2, 50.3, 50.5, 50.6
Accept
Reject
Count
Sack
OUTPUT
[5]
(b) The size of the batch has increased to 50 sacks. It has been decided to only reject sacks that
are underweight.
State the changes that need to be made to the flowchart.
…
…
…
… [2]
Question text
6
A database table, TRAIN, is to be set up for a railway company to keep a record of the engines
available for use. Each engine has a unique number made up of 5 digits, nnnnn. The engines
are classified as freight (F) or passenger (P) together with a power classification that is a whole
number between 0 and 9, for example F8. The railway company keeps a record of the date of the
last service for each engine.
(a) Identify the three fields required for the database. Give each field a suitable name and data
type. Provide a sample of data that you could expect to see in the field.
Field 1 Name …
Data type …
Data sample …
Field 2 Name …
Data type …
Data sample …
Field 3 Name …
Data type …
Data sample … [6]
(b) State the field that you should choose as the primary key.
… [1]
(c) Using the query-by-example grid below, write a query to identify all passenger engines that
have not been serviced in the past 12 months. Only display the engine numbers.
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