Worked solution from the Databases Paper 2 Algorithms, Programming and Logic booklet, Part 2 of 2.
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]
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.
| Code | Description | Quantity_Ordered |
|---|---|---|
| HS50 | Hose (50 metres) | 60 |
| GFLG | Garden Fork | 50 |
| LMPT | Lawn 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]
Use only the three fields wanted. Put the sort on Code and the test on Quantity_Stock. Tick Show for all three.
| Code | Description | Quantity_Stock | |
|---|---|---|---|
| Table | TOOLS | TOOLS | TOOLS |
| Sort | Ascending | ||
| Show | ✓ | ✓ | ✓ |
| Criteria | <25 | ||
| or |
Code column correct (field, table, sort, show) [1]
Description column correct [1]
Quantity_Stock column correct, with criteria <25 [1]
▶ 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.