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

N5 Computing Science 2019 Question 17

15 marks · Data dictionary and validation

The start date for two jobs in the Vacancy table has not been entered. Describe what should be done to ensure that startDate is not left blank. Design a query to display the job title and names of employees at pay grade 2 who have applied for any job in the Production department. Field(s) Table(s) Search criteria The pay grade for H Patel should be pay grade 2 and not pay grade 3. The SQL statement below is written to make the change. UPDATE Employee SET payGrade = 3 WHERE surname = "Patel"; Give two reasons why this SQL statement is not fit for purpose. Reason 1 Reason 2 Re-write the SQL statement to make it fit for purpose. The updated tables below show current job vacancies and employees. Vacancy jobRef jobTitle department startDate Employee appRef jobRef initial surname payGrade drivingLicence cvAttached ☑ ☑ ☑ ☑ ☐ ☑ ☑ ☐ ☐ ☑ ☐ ☑ ☑ ☑ The following SQL statement is implemented in the database. SELECT jobTitle, appRef FROM Vacancy, Employee WHERE Vacancy.jobRef=Employee.jobRef AND drivingLicence=False ORDER BY jobTitle DESC; Write the expected output from the SQL statement. Describe how this expected output could be used to check that the SQL statement works correctly. A company uses a relational database to store details of job vacancies for current employees. Each employee can apply for only one vacancy. The tables below show current job vacancies and employees. Vacancy jobRef jobTitle department startDate Employee appRef jobRef initial surname payGrade drivingLicence cvAttached ☑ ☑ ☑ ☑ ☐ ☑ ☑ ☐ ☐ ☑ ☐ ☑ ☑ ☑

Marking scheme

A presence check (added to the startDate field) Set the field to required One mark each for the following • jobTitle, (initial), surname with no other fields • Vacancy, Employee • department = Production • payGrade = 2 Logical operators and equi-joins are not required in the search criteria as this is design. If logical operators are used then they must produce the correct result. If they do not, the first criteria may be marked correct and subsequent criteria should be marked as incorrect. Field(s) jobTitle, (initial), surname Table(s) Vacancy, Employee Search Criteria department = Production payGrade = 2 Sort Order One mark each for • payGrade should be set to 2 OR there would be no update to payGrade as value is already ‘3’ • there is more than one Patel One mark each for • UPDATE Employee SET payGrade = 2 • WHERE appRef = 327 Also accept WHERE surname=“Patel” AND initial=“H” One mark for • Two correct fields, with correct headings, in correct order One mark for each row of search results • Manager 330 • Clerk 327 • Administrator 329 One mark for • above three rows in descending order of jobTitle. Example output jobTitle Manager Clerk Administrator appRef 330 327 329 If the search results are correct but also contain additional rows then award 2 marks out of 3 available. Actual output would be compared to the predicted results

Previous question: N5 Computing Science 2019 Question 16

Next question: N5 Computing Science 2019 Question 18