ExamBank Scot · N5 Computing Science question bank · All N5 Computing Science questions
12 marks · Query design
Caledonian Wheels want to share details about all the UK based drivers who have had a successful year so far. Design a query to search the database for a driver’s full name, driver number and team name who have won more than three races and drive for a United Kingdom based team. Field(s) Table(s) Search Criteria Describe how the SQL statement could be tested when the query is created. The following SQL statement is implemented in the database. SELECT teamID, teamName, titlesWon FROM Team WHERE (teamID = "PV81" OR location = "Italy") AND titlesWon >=5 Write the expected output from this SQL statement. Jackie West won her 2nd race of the season increasing her points to 50. Write the SQL statement to update Jackie’s details. A new driver is to be added. INSERT INTO Driver (driverNum, forename, surname, wins, points, teamID) VALUES (99, "Thomas", "Webb", 0, 0, "PC81") When this SQL statement is run, an error message is displayed stating that the record cannot be added. Explain why an error message is displayed. Caledonian Wheels organises a motorsport racing championship. A database is used to store data on racing teams and their individual drivers. The data stored in the database is shown below. Team teamID teamName titlesWon location RR32 Rapid Racers 7 Italy SS21 Swift Streaks 3 United Kingdom TT16 Turbo Titans 2 Germany VR12 Velocity Vipers 4 Italy ER54 Elite Racers 1 United Kingdom PV81 Prime Speed 5 Spain Driver driverNum forename surname wins points teamID 1 Shannon Kelly 5 125 ER54 3 Ezri Wuzik 2 50 PV81 4 Jackie Price 2 50 RR32 11 Kai West 4 100 SS21 14 Charlie Wilkinson 1 25 TT16 18 Moss Gray 0 0 VR12 22 Kris Hunt 1 25 SS21 31 Meenal Ibrahim 3 75 VR12 55 Ollie Graham 6 150 TT16 63 Gerry Fox 0 0 PV81 77 Jackie West 1 25 ER54 81 Akari Ogawa 0 0 RR32
Field(s) • forename, surname, driverNum, teamName Table(s) • Team, Driver Search Criteria • wins >3 • location= "United Kingdom" Candidates may express answers differently eg wins >= 4 Field(s) • fields can be in any order • do not award a mark if additional fields have been included Table(s) • table names can be in any order Search Criteria • conditions can be in any order • equi-join not required Quotes not required. Compare expected results to actual results. • Headings: - teamID, teamName, titlesWon • Rows: - PV81 Prime Speed 5 - RR32 Rapid Racers 7 Award 1 mark for three correct headings, in correct order. Award 1 mark for both rows of the search results in any order. • UPDATE driver • SET points = 50 • wins = 2 • WHERE driverNum = 77 The two update values in SET may be either way round. The first update value requires SET. Ignore syntax error where a comma is missing in SET or the comma has been replaced with AND Also award the WHERE mark for forename = Jackie AND surname = West • explanation of referential integrity with reference to the team • teamID (‘PC81’) does not exist (in the ‘Team’ table) Award 1 mark for any one bullet. Naming the teamID is not required as only one is included in the question.