Question bank › A-level › A-level Computer Science › Fundamentals of databases

SQL and client–server databases

10 questions47 marksabout 55 min

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

1Standard4 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]

2Stretch6 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]

3Standard4 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]

Stuck on SQL and client–server databases?

Get it sorted in a free 30-minute session

We work through your weakest questions on this topic on Zoom. I reply the same day.

4Hard5 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]

5Core4 marks

A gym stores class bookings in a table:

Booking(BookingID, MemberID, ClassName, ClassDate)

ClassDate is stored as a date. The gym's database runs on a central server and staff use it from several client computers at the same time.

(a) Write an SQL statement to remove every booking for a class that took place before 1 September 2026. [2]

(b) Give two advantages to the gym of storing the database on a server that is accessed by client computers, rather than keeping a separate copy of the data on each computer. [2]

6Standard5 marks

A library database already contains the tables Member(MemberID, Surname, Email) and BookCopy(CopyID, ISBN, Shelf). MemberID and CopyID are both integers.

A new table, Loan, is needed with these fields:

  • LoanID: a whole number that uniquely identifies each loan
  • CopyID: the copy of the book that has been borrowed
  • MemberID: the member who borrowed it
  • DateOut: the date the copy was borrowed
  • Returned: true if the copy has been brought back, otherwise false

Write the SQL statement that would create the Loan table, including suitable data types and all keys. [5]

7Standard4 marks

A football league stores data in two tables.

Team

TeamIDTeamName
T1Rovers
T2Albion
T3City

Player

PlayerIDSurnameTeamIDGoals
101HaleT27
102MensahT112
103ItoT34
104ByrneT19
105KaurT215
SELECT Player.Surname, Team.TeamName
FROM Player INNER JOIN Team ON Player.TeamID = Team.TeamID
WHERE Player.Goals > 8
ORDER BY Team.TeamName ASC, Player.Surname DESC

(a) Write down the results that would be produced by this query, as a table with the rows in the correct order. [3]

(b) Explain the purpose of ON Player.TeamID = Team.TeamID in the query. [1]

8Hard5 marks

A medical centre uses these tables:

Doctor(DoctorID, Surname, Room)
Patient(PatientID, FirstName, Surname, DateOfBirth)
Appointment(ApptID, PatientID, DoctorID, ApptDate, ApptTime)

Write an SQL query to list the first name and surname of every patient who has an appointment with the doctor whose surname is Okafor on 14 November 2026, together with the time of each appointment. The results must be shown with the earliest appointment first. [5]

9Hard4 marks

An online shop's client–server database uses timestamp ordering for concurrency control. Every transaction is given a timestamp when it starts, and each record holds a read timestamp and a write timestamp.

Two transactions, T1 (timestamp 10) and T2 (timestamp 20), both access the Stock field of the same product record. The order in which their operations are requested is shown in Figure 1.

(a) State the read timestamp and the write timestamp of the record immediately after step 3 has been carried out. [2]

(b) Explain what the DBMS will do when T1 requests the write at step 4, and why. [2]

StepT1 (timestamp 10)T2 (timestamp 20)1Read Stock (value 30)2Read Stock (value 30)3Write Stock = 224Write Stock = 25Time runs downwards. Before step 1: read timestamp = 0, write timestamp = 0 for Stock.
10Stretch6 marks

A ticket agency's database is held on a server. Two booking clerks, A and B, work at different client computers. The record for a concert holds the field TicketsLeft, which currently contains 40.

Clerk A sells 5 tickets and Clerk B sells 12 tickets at almost the same moment. No concurrency control is used. The operations happen in this order:

  1. A reads TicketsLeft
  2. B reads TicketsLeft
  3. A writes its new value of TicketsLeft
  4. B writes its new value of TicketsLeft

(a) State the value of TicketsLeft after step 4 and the value it should have. [2]

(b) Explain why the value after step 4 is incorrect. [1]

(c) The DBMS could instead use serialisation or commitment ordering. Describe how each method would prevent the problem shown in part (a). [3]

Stuck on this topic?

Book a free 30-minute session on WhatsApp and we'll find exactly which step is costing you the marks. Or build a timed paper on it.

Free 30-minute session