ExamBank Scot · N5 Computing Science question bank · All N5 Computing Science questions

N5 Computing Science 2021 Question 17

10 marks · Query design

Design a query that would output the model, number of seats and the showroom manager for all the Jaguar cars located in Glasgow. Field(s) Table(s) Search criteria An SQL statement is implemented to find all two seater cars and produces the output below. make model salePrice Alfa Romeo Giulia 50000 Alfa Romeo GTV 35000 Alfa Romeo Spider 66000 Fiat Spider 124 26345 Jaguar F‑Type 105200 Jaguar XJS 45595 Jaguar XKR 70000 Lotus Evora 72500 Mazda MX‑5 21987 Porsche Cayman 718 40000 Write the SQL statement that will produce this output, in the order shown. One functional requirement is to output the make, model and price of cars costing less than 60000 which are not in Glasgow. SELECT make, model, colour, salePrice FROM Car WHERE showroomID = "Abd" AND salePrice < 60000; Give two reasons why the SQL statement would not produce the required output. Reason 1 Reason 2 A car retailer has four showrooms. A relational database is used to store details of the four showrooms and the cars they have for sale. Showroom showroomID city manager Gla1 Glasgow Ray Rain Gla2 Glasgow Kate Jones Abd Aberdeen Sue Gearan Dun Dundee Sadiq Yavuz Car carID make model colour seats salePrice showroomID 1 McLaren F1 blue 3 900000 Dun 2 Jaguar XKR silver 2 70000 Gla1 3 SMART Sports green 3 22300 Abd 4 Nissan GT‑R red 4 80000 Dun 5 Alfa Romeo Giulia green 2 50000 Dun 6 Audi TT Coupe white 4 12050 Gla2 7 Mazda MX‑5 black 2 21987 Abd 8 Jaguar F‑Type red 2 105200 Dun 9 SMART Sports yellow 3 17000 Gla1 … … … … … … …

Marking scheme

Correct fields (1 mark) o Model, seats, manager Both tables (1 mark) o Showroom, Car Criteria identified (2 marks) o Make = Jaguar o City = Glasgow Second criteria could also be written as: showroomID = "Gla1" AND showroomID = "Gla1" One mark each for • SELECT make, model, salePrice • FROM Car • WHERE seats = 2 • ORDER BY make ASC, model ASC; As SQL defaults to sorting by ascending order, both ASCs could be omitted. One mark each for • Extra column displayed • Output does not include the Dundee showroom

Previous question: N5 Computing Science 2021 Question 16

Next question: N5 Computing Science 2021 Question 18