2210/21/M/J/20 question 6: worked solution (May/June 2020, paper 21)

Show as plain text

Cambridge O Level Computer Science 2210 · 9.4 Structured query language (SQL) Worked solution from the Databases Paper 2 Algorithms, Programming and Logic booklet, Part 2 of 2. Q2 2210/21/M/J/20 original Q6 Structured · 7 marks 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. 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] (c) 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] KEY IDEA Read 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 VIDEO ▶ Topic lesson A lesson on this topic · by Mr Bulmer's Learning Zone. Tap the picture to open it on YouTube.