Databases and SQL – IGCSE Computer Science (0478)
Question text
5
A database table, NURSE, is used to keep a record of disposable items worn by veterinary nurses.
This is part of the table:
ItemNumber
Description
SingleUse
Uses
StockLevel
ReorderLevel
DIG1
Glove (pair)
Y
1
500
800
DIA1
Apron
Y
1
700
800
DIM5
Hair net
Y
1
650
500
DIA2
Apron
N
5
25
100
DIS4
Suit
N
3
70
50
DIV9
Shoe cover (pair)
Y
1
400
250
(a) Complete this query-by-example grid to display only the item number and the description of
single use items, where the stock level is below the reorder level.
Field:
Table:
Sort:
Show:
Criteria:
or:
[4]
(b) Give a reason why the field SingleUse is not required in the table NURSE.
…
… [1]
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
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
Question text
6
A business uses a closed-circuit television (CCTV) system that starts recording when motion is
detected. It stops recording after two minutes if no further motion is detected. The system uses a
motion sensor and a microprocessor.
Describe how the motion sensor and microprocessor work together to control the CCTV system.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [7]
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]
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
Question text
8
An electronic game has three square mats that are coloured red, green and blue.
The player will see a colour displayed on a screen and has 1 second to hit the mat that matches
the colour. If the player hits the correct mat, within 1 second, a counter is incremented. When a
player hits an incorrect mat, the game ends.
The game uses sensors and a microprocessor to determine if the player hits the correct mat within
1 second.
Explain how the game uses sensors and a microprocessor to count the number of times a player
hits a correct mat within 1 second.
…
…
…
…
…
…
…
…
…
…
…
…
…
… [7]
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]
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
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
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]
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
Question text
9
An underground car park has a system that checks the height of vehicles. A vehicle can be no
higher than 1.8 metres to enter the car park.
The system also counts the number of vehicles that have entered the car park, so that it can
display how many parking spaces are still available.
Each parking space has a red and a green light above it. If a car is parked in the parking space
only the red light is on, otherwise only the green light is on.
Sensors and a microprocessor are used to control the system.
(a) Complete the table to identify a suitable sensor for each part of the system.
Task
Sensor
check if a vehicle is too high
count the vehicles entering the car park
check if a vehicle is parked in a parking space
[3]
(b) Describe how the sensor and the microprocessor are used to display the red or green light
above the parking space.
…
…
…
…
…
…
…
…
…
…
… [6]
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
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
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.
…
…
…
…
…
…
…
…
…
…