Databases and SQL – IGCSE Computer Science (0478)

116 questions · page 3 of 8 · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
31
0478/22/O/N/23 · Question 10Oct/Nov 2023Paper 228 marks
Loading question…
Question text

10 A database table called Horses stores details about the horses kept at a horse sanctuary.
Code
Breed
BreedOrigin
Gender
Age
Arrived
H002
Arabian
Saudi Arabia
M
5
28/09/2022
H004
Percheron
France
M
5
30/10/2022
H010
Friesian
Netherlands
M
6
15/11/2022
H011
Fjord
Norway
F
4
17/11/2022
H012
Clydesdale
Scotland
M
10
18/11/2022
H015
Arabian
Saudi Arabia
F
5
15/12/2022
H016
Arabian
Saudi Arabia
F
5
15/12/2022
H017
Clydesdale
Scotland
F
4
16/01/2023
H019
Percheron
France
M
3
16/01/2023
H025
Percheron
France
M
7
16/01/2023
H026
Clydesdale
Scotland
F
9
20/01/2023
H030
Clydesdale
Scotland
M
12
20/01/2023
H032
Fjord
Norway
M
3
24/03/2023
H033
Arabian
Saudi Arabia
F
15
27/04/2023
H034
Clydesdale
Scotland
F
4
14/06/2023
H035
Fjord
Norway
M
7
15/06/2023
H036
Friesian
Netherlands
F
15
20/07/2023
H037
Friesian
Netherlands
M
12
20/07/2023
(a) State the number of records in this database table.
… [1]
(b) Give the name of the field that is most suitable to be the primary key.
State the reason for this choice.
Field …
Reason …
…
[2]
(c) The database only allows the data types:
•
Boolean
•
character
•
date/time
•
integer
•
real
•
text.
Complete the table to show the most appropriate data type for each field.
Each data type must be different.
Field
Data type
Breed
Gender
Age
Arrived
[2]
(d) Complete the structured query language (SQL) to return the code and breed of all the horses
whose breed originated in Scotland.
… Code, Breed,
FROM …
WHERE … = "Scotland";
[3]

32
0478/23/O/N/23 · Question 9Oct/Nov 2023Paper 2311 marks
Loading question…
Question text

9
A sanctuary for pheasants has set up a new database table called PheasantList to store details
of the different species of bird at the sanctuary. Part of this table is given, showing: species,
description, number of birds at the sanctuary, if the birds are breeding or not, and number of
young born this year.
Species
Description
NumberBirds
Breeding
Young
Edwards
blue-black with white tail
5
Yes
0
Japanese green
dark green with pale grey tail
2
Yes
2
Reeves
golden, white and red scaled plumage
4
Yes
1
Crawfords Kalij
glossy blue-black plumage
4
No
0
Crested fireback
blue-black with black tail
3
No
0
True silver
white laced top half and black lower half
7
Yes
1
Siamese fireback
grey plumage with crimson legs and feet
5
No
0
Mikado
iridescent plumage with white striped wings
3
Yes
4
Red junglefowl
many colours
2
Yes
0
Himalayan monal
many colours with metallic green crest
3
Yes
2
White eared
white with ear tufts
5
Yes
3
Brown eared
brown with ear tufts
9
Yes
1
Ring necked
long tail with white ring neck
2
Yes
2
Golden
rainbow coloured
3
Yes
4
(a) State the number of records and fields in this part of the database table.
Records …
Fields …
[2]
(b) (i)
Give the name of a field that could be used for the primary key.
… [1]
(ii)
Explain why the sanctuary might decide not to use the field in (b)(i) as the primary key.
…
… [1]
(iii)
A new field SpeciesID is added to the database table.
This field contains a six-character code, for example Ph0001.
Give a reason why this field would be a better primary key.
…
… [1]
(c) Write the output that would be given by this structured query language (SQL) statement:
SELECT Species, Description
FROM PheasantList
WHERE NumberBirds > 6;
…
… [2]
(d) Complete this SQL statement to display all the species of pheasant where the birds are
breeding and there were no young born this year:
SELECT …
FROM …
WHERE …
… ;
[4]

33
0478/21/M/J/23 · Question 10May/June 2023Paper 218 marks
Loading question…
Question text

10 A database table called TVRange shows the main features and prices of a range of televisions.
TVCode
ScreenSize
Satellite
SmartTV
SoundBar
Price$
TV90SaSmSd
90
YES
YES
YES
9750.00
TV75SaSmSd
75
YES
YES
YES
8500.00
TV75SaSd
75
YES
NO
YES
8000.00
TV65SaSmSd
65
YES
YES
YES
6000.00
TV65SmSd
65
NO
YES
YES
5000.00
TV65SaSd
65
YES
NO
YES
5000.00
TV55SaSmSd
55
YES
YES
YES
4000.00
TV55SaSd
55
YES
NO
YES
3500.00
TV55SmSd
55
NO
YES
YES
3500.00
TV50SaSmSd
50
YES
YES
YES
2500.00
TV50Sa
50
YES
NO
NO
1750.00
TV50Sm
50
NO
YES
NO
1750.00
TV40Sa
40
YES
NO
NO
1200.00
TV40
40
NO
NO
NO
950.00
TV32
32
NO
NO
NO
650.00
(a) Give the name of the field that is most suitable to be the primary key.
State the reason for this choice.
Field …
Reason …
…
[2]
(b) The database uses the data types:
•
text
•
character
•
Boolean
•
integer
•
real
•
date/time.
Complete the table to show the most appropriate data type for each field.
Each data type must be different.
Field
Data type
TVCode
ScreenSize
SmartTV
Price$
[2]
(c) Complete the structured query language (SQL) query to return the television (TV) code,
screen size and price of all Smart TVs in the database table.
SELECT TVCode, … , …
… TVRange
WHERE SmartTV = … ;
[4]

Advertisement
34
0478/22/M/J/23 · Question 5May/June 2023Paper 225 marks
Loading question…
Question text

5
Circle five file-handling operations.
calculate
close
count
create
input
open
output
print
read
sort
search
test
total
write
[5]

35
0478/22/M/J/23 · Question 10May/June 2023Paper 226 marks
Loading question…
Question text

10 A music streaming service has a new database table named Songs to store details of songs
available for streaming. The table contains the fields:
•
SongNumber – the catalogue number, for example AG123
•
Title – the title of the song
•
Author – the name of the song writer(s)
•
Singer – the name of the singer(s)
•
Genre – the type of music, for example rock
•
Minutes – the length of the song in minutes, for example 3.75
•
Recorded – the date the song was recorded.
(a) Identify the field that will be the most appropriate primary key for this table.
… [1]
(b) Complete the table to identify the most appropriate data type for the fields in Songs
Field
Data type
SongNumber
Title
Recorded
Minutes
[2]
(c) Explain the purpose of the structured query language (SQL) statements.
SUM (Minutes) FROM Songs WHERE Genre = "rock";
COUNT (Title) FROM Songs WHERE Genre = "rock";
…
…
…
…
…
… [3]

36
0478/23/M/J/23 · Question 6May/June 2023Paper 239 marks
Loading question…
Question text

6
An algorithm has been written in pseudocode to allow 100 positive numbers to be input. The total
and the average of the numbers are output.
100
01
Counter
0
02
Total
03
WHILE Counter > 100 DO
04
INPUT Number
05
IF Number > 0
06
THEN
Total + Counter
07
Total
Counter + 1
08
Counter
09
ENDCASE
10
ENDWHILE
11
OUTPUT "The total value of your numbers is ", Total
12
OUTPUT "The average value of your numbers is ", Total / 100
(a) Identify the four errors in the pseudocode and suggest corrections.
Error 1 …
Correction …
…
Error 2 …
Correction …
…
Error 3 …
Correction …
…
Error 4 …
Correction …
…
[4]
(b) Describe the changes you should make to the corrected algorithm so that a count-controlled
loop is used to allow 100 positive numbers to be input.
You do not need to rewrite the algorithm.
…
…
…
…
…
…
…
…
…
… [5]

37
0478/23/M/J/23 · Question 10May/June 2023Paper 238 marks
Loading question…
Question text

10 A database table called Site1 stores details of some holiday homes at a holiday park. The
database shows the type of home, number of guests, whether it is privately owned and the weekly
rate to hire it.
Name
Type
Private
Rate$
NumberGuest
Bay Lodge
Lodge
NO
1000
10
Bay View
Cabin
NO
400
4
Blue Skies
Cabin
NO
350
4
Cliff View
Cabin
NO
650
6
Coppice Lodge
Lodge
NO
1200
12
Green Lodge
Lodge
NO
1000
8
Henry
Cabin
YES
300
2
Hikers’ Rest
Retreat
NO
750
6
Poppy
Cabin
NO
300
2
Summer Joy
Retreat
YES
750
6
Valley View
Cabin
NO
600
6
West Lodge
Lodge
YES
1200
12
(a) State the number of fields and the number of records in this database table.
Fields …
Records …
[2]
(b) Describe the purpose of a primary key.
…
… [1]
(c) The database uses the data types:
•
alphanumeric
•
character
•
Boolean
•
integer
•
real
•
date/time.
Complete the table to show the most appropriate data type for each field.
Field
Data type
Type
Private
Rate$
NumberGuest
[2]
(d) Give the output that would be produced by the structured query language (SQL) statement:
SELECT Name, NumberGuest, Rate$
FROM Site1
WHERE NumberGuest >= 10;
…
…
…
…
…
… [3]

38
0478/22/F/M/23 · Question 9Feb/March 2023Paper 229 marks
Loading question…
Question text

9
A shop that sells books has set up a new database table called BookList to store book details.
Part of this table is given.
CatNo
Title
Fiction
Author
PaperBack
Price StockLevel
BK01
The Princes’ Story
Yes
B Penn
Yes
4.50
500
BK02
The Princesses’ Story
Yes
B Penn
Yes
4.50
350
BK03
Computer Science
No
Way Yu
Yes
19.99
20
BK04
The Modern World
No
P Patel
No
25.00
5
BK05
The Ancient World
Yes
P Patel
No
25.00
5
BK06
Computer Science
No
R Dale
Yes
27.35
8
BK07
The Princes’ Story
Yes
B Penn
No
12.50
3
BK08
The Princesses’ Story
Yes
B Penn
No
12.50
0
BK12
Famous Five
Yes
E Bly
Yes
2.75
45
BK15
Secret Seven
Yes
E Bly
Yes
2.75
25
BK16
The Last Knight
Yes
P Mann
Yes
5.99
7
BK17
The Dark Tower
Yes
P Mann
Yes
5.99
5
BK19
The Final Chase
Yes
P Mann
Yes
5.99
5
BK21
Maths Today Part 1
No
B Ward
Yes
6.75
25
BK22
Maths Today Part 2
No
B Ward
Yes
6.75
15
BK23
Maths Today Part 3
No
B Ward
Yes
6.75
10
BK26
Maths Today Workbook
No
B Ward
Yes
6.75
30
BK27
Knitting for Beginners
No
A Smith
Yes
6.99
3
BK30
Woodwork for Beginners
No
A Smith
Yes
6.99
4
BK31
Networking for Beginners
No
A Smith
Yes
6.99
0
(a) State the number of records in this part of the database table.
… [1]
(b) (i)
Give the name of the field that would 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 identify the most appropriate data type for each field based on the data
shown in the table BookList
Field
Data type
CatNo
Title
Fiction
Price
[2]
(d) Write the output from this structured query language (SQL) statement.
SELECT CatNo, Title, Author
FROM BookList
WHERE StockLevel = 0;
…
…
…
… [2]
(e) Complete this SQL statement to display all the titles by the author B Penn.
SELECT …
FROM …
WHERE … ;
[2]

Advertisement
39
0478/21/O/N/22 · Question 5Oct/Nov 2022Paper 215 marks
Loading question…
Question text

5
A database table, WAREHOUSE, is used to keep a record of items for sale. The table has these
fields:
•
ItemCode – code to identify each type of item
•
Description – brief description of each item
•
Manufacturer – name of manufacturer
•
Level – number in stock
•
Price – price in dollars ($).
(a) State which field you would choose for the primary key. Give a reason for your choice.
Field …
Reason …
…
[2]
(b) Complete the query-by-example grid to display only the item code and the manufacturer
where the number in stock is below 10.
Field:
Table:
Sort:
Show:
o
o
o
o
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

40
0478/22/O/N/22 · Question 7Oct/Nov 2022Paper 228 marks
Loading question…
Question text

7
A school uses a database table, ASSESS, to keep a record of the internal assessments and the
number of candidates for each of the subjects in its curriculum.
SubjectCode
SubjectName
Exams
Practicals
Candidates
COMP
Computer Science
2
1
200
INFO
Information Technology
1
2
200
MATH
Mathematics
3
0
350
PHYS
Physics
2
1
120
CHEM
Chemistry
2
1
120
BIOL
Biology
2
1
200
GEOG
Geography
2
0
200
HIST
History
2
0
250
GEOL
Geology
2
0
80
PHED
Physical Education
1
2
350
FREN
French
2
2
120
ENGL
English
2
2
350
This database only allows the data types:
•
text
•
number
•
currency
•
Boolean.
(a) (i)
State the most appropriate data type for the fields SubjectCode and Exams.
SubjectCode …
Exams …
[1]
(ii)
State one reason why the Candidates field could not be of the Boolean data type.
…
… [1]
(b) Show the output given by the query-by-example grid.
Field:
SubjectName
Practicals
Candidates
Table:
ASSESS
ASSESS
ASSESS
Sort:
Ascending
Show:
3
3
Criteria:
<1
or:
…
…
…
…
…
… [3]
(c) Complete the query-by-example grid to output the subjects with fewer than 150 candidates.
Display only the SubjectCode, SubjectName and Candidates fields in order of the number of
candidates from largest to smallest.
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 Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge

41
0478/23/O/N/22 · Question 5Oct/Nov 2022Paper 235 marks
Loading question…
Question text

5
A database table, MUSEUM, is used to keep a record of items in the museum. The table has
these fields:
•
ItemCode – code for each type of item, for example ART0005
•
Description – brief description of each item, for example gold coin
•
InStore – whether the item is in store or not, for example Y
•
Century – century when item made, for example 18
•
Country – country of origin, for example China.
(a) Identify which field you would choose for the primary key.
State a reason for your choice.
Field …
Reason …
…
[2]
(b) Complete the query-by-example grid to display only the description and the country of origin
for those items not in store.
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 Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge

42
0478/21/M/J/22 · Question 4May/June 2022Paper 2110 marks
Loading question…
Question text

4
The flowchart shows an algorithm that should allow 60 test results to be entered into the variable
Score. Each test result is checked to see if it is 50 or more. If it is, the test result is assigned to the
Pass array. Otherwise, it is assigned to the Fail array.
(a) Complete this flowchart:
START
PassCount
0
FailCount
0
Count
0
Yes
No
Count
Count + 1
No
Yes
END
[6]
(b) Write a pseudocode routine that will check that each test result entered into the algorithm is
between 0 and 100 inclusive.
…
…
…
…
…
…
…
…
…
… [4]

43
0478/21/M/J/22 · Question 6May/June 2022Paper 215 marks
Loading question…
Question text

6
A computer game shop records its stock levels in a database table called GAMES. The fields used
in the stock table are shown.
Name
Description
GameID
primary key
GameName
the name of each game
AgeRestriction
the minimum age at which a person is allowed to play each game
GamePrice
the selling price for each game
NumberStock
the quantity of each game currently in stock
whether or not each game is on order from the suppliers
OnOrder
DateLastOrdered
the date the most recent order for each game was placed
GameDescription
a summary of the contents and purpose of each game
(a) State the number of fields that are in the table GAMES.
… [1]
(b) State one important fact that must be true for a field to be a primary key.
…
… [1]
(c) Complete the query-by-example grid to output all the games that have no stock and that are
on order with the supplier. Display only the GameID, GameName and GamePrice fields in
alphabetical order of the name of the game.
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 Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge

Advertisement
44
0478/22/M/J/22 · Question 4May/June 2022Paper 229 marks
Loading question…
Question text

4
This algorithm checks the temperature of hot food being served to customers.
Error
START
Counter
0
Hot
0
Cold
0
Serve
0
INPUT Temp
Yes
Error
Is Temp
((Hot + Cold) / Counter) * 100
= –1?
No
Yes
OUTPUT
Is Temp
Hot
Hot + 1
"Too Hot"
> 86?
No
Counter
Counter + 1
OUTPUT
Error
Yes
Is Temp
Cold
Cold + 1
< 63?
No
OUTPUT
"Too Cold"
Serve
Serve + 1
END
(a) Complete the trace table for the algorithm using this input data:
75, 78, 84, 87, 91, 80, 75, 70, 65, 62, –1, 20
Counter
Hot
Cold
Serve
Temp
Error
OUTPUT
[7]
(b) State how the final output from the algorithm could be improved.
…
… [1]
(c) Identify the process in the algorithm that is not required.
…
… [1]

45
0478/22/M/J/22 · Question 5May/June 2022Paper 225 marks
Loading question…
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

Advertisement