Databases and SQL – IGCSE Computer Science (0478)
116 questions · page 8 of 8 · Clear filters
Question text
6
A database table, DEVICE, has been set up to record the electronic equipment used in a small
business.
Device ID
Device Type
User
Purchase
Purchase
Portable
Date
Price ($)
3
Desktop
Alan Swales
14/02/2017
1350.00
N
4
Laptop
Chantel Law
01/02/2016
1460.00
Y
5
Tablet
Abdula Saud
31/12/2016
1000.00
Y
6
Desktop
Abdula Saud
14/03/2017
1000.00
N
7
Laptop
Alan Swales
15/03/2016
1700.00
Y
8
Tablet
Taona Jaji
16/12/2016
470.00
Y
(a) The query-by-example grid below selects certain records.
Field:
User
Portable
Purchase Price ($)
Table:
DEVICE
DEVICE
DEVICE
Sort:
Ascending
Show:
3
Criteria:
Y
>1000
or:
Show what would be the output from the query-by-example.
…
…
… [2]
(b) Complete the query-by-example grid below to select all Desktop devices that were either
purchased before 31/12/2016 or cost under $1000. Only show the Device ID and Device
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
2
Read this section of program code that:
•
inputs 10 numbers
•
checks whether each number is within a specified range
•
totals the numbers within the range and outside the range
1
InRange = 0
2
OutRange = 1000
3
FOR Count = 1 TO 10
4
INPUT Num
5
IF Num > 10 AND Num < 20 THEN InRange = InRange + 1
6
ELSE OutRange = OutRange - 1
7
Count = Count + 1
8
NEXT X
9
PRINT InRange, OutRange
(a) There are four errors in this code.
Locate these errors and suggest a correction to remove each error.
Error 1 …
Correction …
…
Error 2 …
Correction …
…
Error 3 …
Correction …
…
Error 4 …
Correction …
… [4]
(b) Decide, with reasons, whether the numbers 10 and 20 are within or outside the range.
Within
Outside
Number
Reason
range (✓)
range (✓)
10
… ..
… ..
20
… ..
… ..
[4]
Question text
6
A database, THEATRETOURS, was set up to show the tour dates, towns, number of seats and
prices in local currency for a Shakespeare play.
Town
Tour Date
Number of Seats
Price Local Currency
Wigan
18/08/2016
120
15.00
Dumfries
20/08/2016
160
12.50
Turin
25/08/2016
200
17.00
Macon
27/08/2016
75
18.00
Bordeaux
29/08/2016
170
20.00
Algiers
01/09/2016
125
1350.00
Windhoek
05/09/2016
65
90.00
Windhoek
06/09/2016
65
90.00
Port Elizabeth
10/09/2016
200
110.00
(a) Explain why none of the fields in the database can be used as a primary key.
…
…
… [2]
(b) State a field that could be added as a primary key.
…
Give a reason for choosing this field.
…
… [2]
(c) Use the query-by-example grid below to provide a list of tour dates and seat prices in
alphabetical order of town.
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 reasonable
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
Read this section of program code that inputs positive numbers, discards any negative numbers
and then outputs the average. An input of zero ends the process.
1
Total = 0
2
Counter = 100
3
REPEAT
4
REPEAT
5
INPUT Num
6
UNTIL Num < 0
7
Total = Total + 1
8
Counter = Counter + Num
9
UNTIL Num = 0
10
Average = Total / (Counter - 1)
11
Print Average
There are four errors in this code.
Locate these errors and suggest a correction to remove each error.
Error 1 …
Correction …
…
Error 2 …
Correction …
…
Error 3 …
Correction …
…
Error 4 …
Correction …
… [8]
Question text
5
A database, PLAYPRODUCTION, was set up to show the performance dates, prices and number
of seats available at a theatre specialising in Shakespeare productions.
Number
Number
Performance
Price Stalls
Price Circle
Play
Seats
Seats
Date
Seats $
Seats $
Stalls
Circle
As You Like It
01/07/2016
120
90
20.00
30.00
As You Like It
02/07/2016
85
45
30.00
40.00
As You Like It
09/07/2016
31
4
30.00
40.00
Macbeth
14/07/2016
101
56
25.00
35.00
Macbeth
15/07/2016
50
34
25.00
35.00
Macbeth
16/07/2016
12
5
35.00
50.00
Julius Caesar
22/07/2016
67
111
20.00
20.00
Julius Caesar
23/07/2016
21
24
15.00
15.00
A Comedy of Errors
30/07/2016
45
36
35.00
45.00
(a) Give the number of fields that are in each record.
… [1]
(b) State the data type you would choose for each of the following fields.
Play …
Number Seats Stalls …
Price Stalls Seats $ … [3]
(c) The query-by-example grid below selects all the productions with more than 100 seats left in
either the stalls or the circle.
Field: Play
Performance Date
Number Seats Stalls
Number Seats Circle
Table: PLAYPRODUCTION
PLAYPRODUCTION
PLAYPRODUCTION
PLAYPRODUCTION
Sort: Ascending
Show:
Criteria:
> 100
or:
> 100
Show what would be output from the query-by-example.
…
…
… [3]
(d) Complete the query-by-example grid below to select all the productions with at least six seats
left in the circle and show the Play, Performance Date and Price Circle Seats $ in Performance
Date order.
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 reasonable
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
Read this section of program code that inputs 10 positive numbers and then outputs the smallest
number input.
1
Small = 1000
2
Counter = 0
3
REPEAT
4
INPUT Num
5
IF Num < Small THEN Small = Num
6
Counter = Counter + 1
7
UNTIL Counter = 10
8
PRINT Small
(i)
Identify three changes you would need to make to find the largest number input instead
of the smallest number.
1 …
…
2 …
…
3 …
… [3]
(ii)
Rewrite the program code with your changes.
…
…
…
…
…
…
…
… [3]
Question text
3
A program will be written to store information about members of a swimming club.
The following membership details will be recorded:
•
Name
•
Gender
•
Status:
•
Senior
•
Junior
•
Fee
•
Team member (Yes or No)
(i)
Choose a suitable data type for each of the membership details to be recorded.
Membership details
Data type
Name
Gender
Status
Fee
Team member
[5]
(ii)
The swimming club has 50 members.
State the data structure that would be most suitable to use and give a reason for your
choice.
Data structure …
Reason …
… [2]
Question text
6
A database, STAFFPHONE, was set up to show the telephone extension numbers for members of
staff working in a department store.
Name
Department
Extension number
Jane Smith
Toys
129
Sue Wong
Books
124
David Chow
Toys
129
Amy Tang
Household
123
Joe Higgs
Books
124
Jane Smith
Shoes
125
Adel Abur
Shoes
125
Peter Patel
Toys
129
(a) Explain why none of the fields in the database can be used as a primary key.
…
…
… [2]
(b) State a field that could be added as a primary key.
…
Give a reason for choosing this field.
…
… [2]
(c) Use the query-by-example grid below to provide a list of all members of staff, in alphabetical
order, grouped by department.
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 reasonable
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
Read this section of program code that inputs 10 positive numbers and then outputs the total.
1
Total = 0
2
Counter = 0
3
REPEAT
4
INPUT Num
5
Total = Total + Num
6
PRINT Total
7
Counter = Counter + 1
8
UNTIL Counter = 10
This code works, but it is inefficient.
(i)
Suggest three improvements that could be made.
1 …
…
2 …
…
3 …
… [3]
(ii) Rewrite the program code with your improvements.
…
…
…
…
…
…
…
…
…
… [3]
Question text
6
Identify two different selection statements that you can use when writing pseudocode.
1 …
…
2 …
… [2]
Question 7 begins on page 10.
Question text
7
A database, SOFASELECT, was set up to show the prices of suites, sofas and chairs for sale from
an online furniture warehouse. Part of the database is shown below.
Brochure
Number
Number
Description
Material
Colour
Price in $
Number
of Seats
of Pieces
Sofa
SF17
2
1
Leather
Red
950
Sofa
SF19
3
1
Vinyl
Black
1,000
Suite
SU10
4
3
Velvet
Green
1,500
Suite
SU23
5
3
Leather
Brown
950
Recliner chair
RC01
1
1
Leather
Cream
600
Chair
CH16
1
1
Vinyl
Red
250
Recliner sofa
RS23
4
1
Leather
Cream
1,200
Chair
CH10
1
1
Velvet
Red
175
(a) How many fields are in each record?
… [1]
(b) State which field you would choose for the primary key.
…
Give a reason for choosing this field.
…
… [2]
(c) State the data type you would choose for each of the following fields.
Number of Seats …
Price in $ … [2]
(d) The query-by-example grid below selects all the furniture in cream leather.
Field: Description
Material
Colour
Price in $
Brochure Number
Table: SOFASELECT
SOFASELECT
SOFASELECT
SOFASELECT
SOFASELECT
Sort:
Descending
Show:
Criteria:
= ‘Leather’
= ‘Cream’
or:
Show the output from the query-by-example.
…
… [3]
(e) Complete the query-by-example grid below to select and show the brochure number, material,
colour and price of all the furniture with 3 or more seats.
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 reasonable
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