Question bank › A-level Computer Science › Paper 2 – Computer systems

Databases (normalisation, SQL)

Answer on paper first, then reveal the mark scheme one mark at a time.

1Core4 marks

A school database has two tables:

Student(StudentID, Name, FormID)
Form(FormID, Tutor)

(a) State the foreign key in the Student table. [1]

(b) Explain the purpose of a foreign key. [1]

(c) State the type of relationship between Form and Student. [1]

(d) Explain why Tutor is stored in Form rather than in Student. [1]

2Standard4 marks

A table Book(BookID, Title, Genre, Price, Stock) stores books in a shop.

Write an SQL query to display the Title and Price of all Fantasy books costing less than 10, in descending order of price. [4]

3Hard5 marks

A table in first normal form is: Orders(OrderID, ProductID, OrderDate, CustomerID, CustomerName, CustomerCity, ProductName, UnitPrice, Quantity).

The primary key is (OrderID, ProductID). The dependencies are:
OrderID → OrderDate, CustomerID
CustomerID → CustomerName, CustomerCity
ProductID → ProductName, UnitPrice
(OrderID, ProductID) → Quantity

(a) Explain why the table is not in second normal form. [1]

(b) Give a set of tables in third normal form. Write each table as TableName(attribute, attribute, …) and write (PK) after every attribute that is part of that table’s primary key. [4]

4Stretch6 marks

Tables: Student(StudentID, Name, FormID) and Result(ResultID, StudentID, Subject, Mark).

Write an SQL query to display each Subject and the average Mark of students in form '12B' only, showing only subjects whose average is greater than 60. [6]

5Standard4 marks

Using the table Book(BookID, Title, Genre, Price, Stock):

(a) Write an SQL statement to add the book with BookID 6, title 'Sky Fort', genre 'Fantasy', price 7.50 and stock 12. [2]

(b) Write an SQL statement to increase the price of every Fantasy book by 10%. [2]

6Hard5 marks

(a) In a school database, Student.FormID is a foreign key that refers to Form.FormID. Explain what is meant by referential integrity and give an example of an action that would break it in this database. [2]

(b) A bank uses a client–server database. Two clerks open the same account record at the same time and each makes a change to the balance. Explain how record locking prevents one of the updates from being lost. [2]

(c) A transaction that transfers money between two accounts must lock both account records. Explain how this use of record locks could lead to deadlock. [1]

7Standard3 marks

The entity-relationship diagram shows part of a shop's database. A crow's foot at the end of a line shows the ‘many’ side of a relationship.

(a) Identify the relationship that is many-to-many. [1]

(b) Explain how this relationship is implemented in a relational database. [2]

CustomerOrderProduct

Still losing marks on this topic?

Book a free introductory session and we'll find exactly which step is costing you.

Book a free intro