Databases and SQL – IGCSE Computer Science (0478)
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]
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
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
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
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]
Question text
3
This flowchart inputs the marks gained in an examination. An input of –1 ends the routine.
START
Total
0
Count
0
Distinction
0
INPUT Mark
Yes
Is Mark = –1 ?
Total
Total + Mark
Count
Count + 1
No
OUTPUT "Number of
No
Is
Distinctions ", Distinction
Mark >=
OUTPUT "Average Mark "
80 ?
Total/Count
Yes
END
Distinction
Distinction + 1
Complete the trace table for the mark input data: 50, 70, 65, 30, 95, 50, 55, 85, 65, 35, –1, 45
OUTPUT
Total
Count
Distinction
Mark
[4]
Question text
6
A database table, FLIGHT, is used to keep a record of flights from a small airfield. Planes can
carry passengers, freight or both. Some flights are marked as private and only carry passengers.
Flight number
Plane
Notes
Departure time
Passengers
FN101
Caravan 1
Private passenger flight
08:00
Y
CN101
Caravan 2
Freight only
08:30
N
CN102
Piper 1
Freight only
09:00
N
FN104
Piper 2
Passengers only
09:20
Y
FN105
Piper 1
Freight and passengers
10:00
Y
FN106
Caravan 1
Passengers only
10:30
Y
CN108
Caravan 2
Freight only
08:00
N
CN110
Lear
Private passenger flight
08:00
Y
(a) State the field that could have a Boolean data type.
Field … [1]
(b) A query-by-example has been written to display just the flight numbers of all planes leaving
after 10:00 that only carry passengers.
Field:
Flight number
Passengers
Departure time
Table:
FLIGHT
FLIGHT
FLIGHT
Sort:
Show:
3
Criteria:
= Y
= 10:00
or:
Explain why the query-by-example is incorrect, and write a correct query-by-example.
Explanation …
…
…
…
…
Field:
Table:
Sort:
Show:
Criteria:
or:
[7]
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 the weight of 500 items and reject any
that are over-weight or under-weight, then print the percentage rejected.
1
Count
0
Reject
62
Over
58
Under
REPEAT
INPUT ItemWeight
IF ItemWeight > Over AND ItemWeight < Under
THEN
Reject - 1
Reject
ENDIF
Count + 1
Count
UNTIL Count > = 500
Reject / 100
Reject
PRINT "Percentage rejected is ", Reject
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) Describe how you would change the corrected algorithm to calculate the number accepted
instead of rejected, using a variable Accept, and print a warning if fewer than 50% are
accepted.
…
…
…
…
…
…
…
Question text
3
This flowchart inputs the tread depth of five tyres, four on the car and a spare tyre. Any tread
depth of 1.6 mm or less is rejected. To be potentially roadworthy, a car must have four tyres with a
tread depth greater than 1.6 mm.
START
TreadReject
0
Count 1
Is
Yes
Count = 6?
Count
Count + 1
No
Is
No
INPUT Depth
TreadReject
<= 1?
Yes
OUTPUT "Car is
not roadworthy"
No
Is
Depth <=
1.6?
Yes
TreadReject
TreadReject + 1
OUTPUT "Car is
potentially
roadworthy"
END
Complete Trace table 1 for the tread depth input data:
1.7, 1.9, 1.4, 1.8, 2.0
TreadReject
Count
Depth
OUTPUT
Trace table 1
Complete Trace table 2 for the tread depth input data:
1.2, 1.9, 1.4, 1.8, 2.4
TreadReject
Count
Depth
OUTPUT
Trace table 2
[4]
Question text
6
A database table, TRAIN, is used to keep a record of train departures from a station.
Train Number
Platform
Destination
Departure Time
Status
1A37
1
Newtown
08:00
On time
2X19
2
Anytown
08:10
Late
1A29
1
Bigcity
08:15
On time
1A28
2
Anytown
08:30
Cancelled
1A67
3
Gardenvillage
08:45
On time
1A37
1
Newtown
08:50
On time
1A24
2
Charter Train
09:00
Late
1A67
3
Gardenvillage
09:15
On time
(a) Explain why the field Train Number could not be used as a primary key.
…
… [1]
(b) A query-by-example has been written to display only the train numbers and platforms of all
trains leaving after 08:30 that are late.
Field:
Train Number
Platform
Departure Time
Status
Table:
TRAIN
TRAIN
TRAIN
TRAIN
Sort:
Show:
3
Criteria:
= Y
< 08:30
or:
= "Late"
Explain why the query-by-example is incorrect, and write a correct query-by-example.
Explanation …
…
…
…
…
Field:
Table:
Sort:
Show:
Criteria:
or:
[7]
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 and total only the positive
numbers.
←
1
Count
←
Count
Total
REPEAT
INPUT Number
IF Number <> 0
THEN
←
Total + Count
Total
ENDIF
←
Count + 1
Count
UNTIL Count < 50
PRINT Total
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 only total numbers greater than 0
and less than 20.
…
…
… [2]
Question 3 starts on page 10.
Question text
4
For each of the four groups of statements in the table, place a tick in the correct column to show
whether it is an example of Selection or Repetition.
Statements
Selection
Repetition
← 1 TO 10
FOR X
← SUM + 1
SUM
NEXT X
WHILE X > 10 DO
←
SUM
SUM + 1
←
X - 1
X
ENDWHILE
IF X > 10
THEN
←
SUM + 1
SUM
←
X - 1
X
ENDIF
REPEAT
←
SUM
SUM + 1
←
X - 1
X
UNTIL X > 10
[4]
Question text
6
A database table, BIKETYRES, is used to keep a record of tyres for sale in a cycle shop.
Tyres are categorised by width and diameter in millimetres, whether they have an inner tube and
the type of terrain for which they are designed.
Tyre Code
Width
Diameter
Tube
Terrain
Stock Level
SLTT
23
700
YES
Asphalt
18
MLNT
24
700
NO
Asphalt
23
LLNT
28
700
NO
Asphalt
19
SLTM
23
700
YES
Mixed
22
MLTM
24
700
YES
Mixed
14
LLTM
28
700
YES
Mixed
12
SLTH
23
700
YES
Hard
10
MLTH
24
700
YES
Hard
5
LLNH
28
700
NO
Hard
7
SLNM
23
700
NO
Mixed
12
MLNM
24
700
NO
Mixed
22
LLNM
28
700
NO
Mixed
18
SSNT
23
650
NO
Asphalt
10
MSNT
24
650
NO
Asphalt
8
SSTM
23
650
YES
Mixed
5
MSNM
24
650
NO
Mixed
4
The query-by-example grid below displays the tyre code and the stock level of all 28 mm width
tyres suitable for mixed terrain.
Field: Tyre Code
Stock Level
Width
Terrain
Table: BIKETYRES
BIKETYRES
BIKETYRES
BIKETYRES
Sort:
Show:
3
3
Criteria:
= 28
= 'Mixed'
or:
Alter the query to show the tyre code and stock level in ascending order of stock level for all
24 mm asphalt terrain tyres. Write the new query in the following query-by-example grid.
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
An algorithm is written in pseudocode:
0
Total
1 TO 50
FOR Count
INPUT Num
Total + Num
Total
NEXT Count
OUTPUT Total
(a) Describe the purpose of the algorithm.
…
…
…
…
…
… [3]
(b) Re-write the algorithm in pseudocode using a different type of loop.
…
…
…
…
…
…
…
…
…
… [3]
(c) Describe how you could modify the original algorithm shown at the start of question 4, to
allow any number of inputs.
…
…
…
… [2]
Question 5 starts on page 12.
Question text
6
The database table, PCSTOCK, is a part of the database in an electronics shop, showing some of
the desktop (DT), tablet (TB) and laptop (LT) computers they have in stock.
PCID
ScreenSize
RAM
Type
HDD(GB)
Price
DT303240
30
32
DT
4000
$5000.00
DT303220
30
32
DT
2000
$4500.00
DT301620
30
16
DT
2000
$4000.00
DT231610
23
16
DT
1000
$3000.00
LT191620
19
16
LT
2000
$3000.00
LT171610
17
16
LT
1000
$2500.00
DT230820
23
8
DT
2000
$2000.00
DT190810
19
8
DT
1000
$1500.00
LT190810
19
8
LT
1000
$1500.00
LT170805
17
8
LT
500
$1200.00
DT230420
23
4
DT
2000
$1000.00
DT190410
19
4
DT
1000
$750.00
LT190410
19
4
LT
1000
$950.00
TB100206
10
2
TB
64
$200.00
(a) 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
PCID
ScreenSize
Type
Price
[2]
(b) Using the query-by-example grid, write a query to identify all the desktop computers with a
hard drive larger than 1000 GB. All fields in the table should be shown, sorted in descending
order by price.
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