ExamBank Scot · N5 Computing Science question bank · All N5 Computing Science questions
12 marks · Entity-relationship diagrams and keys
Explain the purpose of the foreign key clubID in the Player table. Design a query that could be used to create a list of names and the division for Goal keepers that are over 30 years old. Field(s) Table(s) Search Criteria The netball league wants a list of players who meet at least one of the following criteria: • train in Lanarkshire • play for a team in division 2. Complete the SQL query below. SELECT clubName, name, playerID FROM WHERE Describe how this SQL query should be tested. Explain why it is better to have referential integrity implemented before adding a new player to the netball database. A database stores data on a local netball league. The Club table stores data of the clubs that play in the league. The Player table stores data on each player. Sample data from each table is shown below. Club clubID clubName trainingVenue contactNo division A2706 Joint Forces Glasgow 01415829631 3 B1803 Shooting Stars Renfrewshire 01245668123 2 E0408 Team Titans Glasgow 01415571239 1 P2507 Hot Shots Lanarkshire 01245789456 1 H0311 Throwing Tigers Glasgow 01418529637 2 … … … … … Player playerID name email age position clubID 358 Meenal m.hussain8@blues.com 21 Goal keeper E0408 562 Jacob smithj_47@rt.co.uk 25 Goal shooter A2706 981 Tara taratara2@getmail.com 24 Centre P2507 742 Ibrahim ib0201@blues.com 36 Wing defence E0408 801 Devin smithdev1@getmail.com 30 Goal shooter B1803 129 Amber ambersun9@rt.co.uk 21 Wing attack A2706 232 Xander XanderXander8@rt.co.uk 38 Goal defence E0408 475 Harris mrharris_g@blues.com 36 Goal attack E0408 603 Zohra zohra_lan@getmail.com 32 Centre B1803 … … … … … …
Creates a relationship/Links Club and Player tables • fields – name, division • tables – Player, Club • position = Goal Keeper • age >30 Candidates may express answers differently in design eg age= >30. 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 FROM • Club, Player WHERE • trainingVenue = Lanarkshire division = 2 • OR between two conditions • club.clubID = player.clubID with attached AND FROM • table names can be in any order WHERE • order of search conditions could change Quotes and brackets not required • find expected output. • compare to actual output To ensure the player is linked to an existing team