Cambridge O Level Computer Science 2210 · 9.4 Structured query language (SQL)

Q2 · 2210/21/M/J/20 Q6

Worked solution from the Databases Paper 2 Algorithms, Programming and Logic booklet, Part 2 of 2.

Q22210/21/M/J/20original Q6Structured · 7 marks
Question 6 from 2210/21/M/J/20

Worked solution

(a)

The primary key is the field that has a different value in every record.

Write: it uniquely identifies each product (each record) in TOOLS. [1]

(b)

Work out which records pass all three tests: Price > 40, Quantity_Stock > 0 and Quantity_Ordered > 0. Only GFLG, HS50 and LMPT pass.

Only the ticked fields are shown: Code, Description and Quantity_Ordered. The output is sorted by Quantity_Ordered, largest first.

CodeDescriptionQuantity_Ordered
HS50Hose (50 metres)60
GFLGGarden Fork50
LMPTLawn Mower (Petrol)25

The correct data (the three records, with only those three fields) [1]

The correct format (a row for each record, fields side by side) [1]

The data in the correct order (60, 50, 25) [1]

(c)

Use only the three fields wanted. Put the sort on Code and the test on Quantity_Stock. Tick Show for all three.

CodeDescriptionQuantity_Stock
TableTOOLSTOOLSTOOLS
SortAscending
Show✓✓✓
Criteria<25
or

Code column correct (field, table, sort, show) [1]

Description column correct [1]

Quantity_Stock column correct, with criteria <25 [1]

KEY IDEARead a query-by-example grid column by column: Show decides what appears, Criteria decides which records, Sort decides the order.
TOTAL 7 marks

Official mark scheme

Mark scheme for 2210/21/M/J/20 question 6
VIDEO
▶ Topic lesson

A lesson on this topic · by Mr Bulmer's Learning Zone. Tap the picture to open it on YouTube.

Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.