Track progress, take quizzes and save notes on this lesson.

Free forever · no card needed

Start free
Intermediate

SQL and Client-Server Databases

4.10.4 SQL·4.10.5 Client-server databases

Aligned to the AQA 7517 specification

Level
Intermediate
Reading time
5 min
Published
13 June 2026
Updated
1 July 2026
On this page
  1. 1.SELECT: Querying Data
  2. 2.JOIN: Combining Tables
  3. 3.INSERT, UPDATE, DELETE
  4. 4.CREATE TABLE (DDL)
  5. 5.Client-Server Databases and Concurrent Access
  6. 6.Common Exam Mistakes

Key takeaways

  • SELECT retrieves data, optionally filtered with WHERE and ordered with ORDER BY; JOIN combines rows from related tables, usually on a foreign key.
  • INNER JOIN returns only rows with a match in both tables, while LEFT JOIN returns all rows from the left table with NULL for unmatched right-side columns.
  • UPDATE and DELETE without a WHERE clause affect every row in the table; this is valid SQL that runs without error, so the missing WHERE is a logic error, not a syntax error.
  • DDL (CREATE, ALTER, DROP TABLE) defines database structure, whereas DML (SELECT, INSERT, UPDATE, DELETE) manipulates the data inside it.
  • Concurrent access risks the lost update problem; record locking, serialisation, timestamp ordering and commitment ordering control it, but locking introduces a deadlock risk.

SELECT: Querying Data

SELECT retrieves data from one or more tables.

SELECT column1, column2
FROM TableName
WHERE condition
ORDER BY column ASC|DESC;

Examples:

-- All students with grade > 70
SELECT Name, Grade
FROM Student
WHERE Grade > 70
ORDER BY Grade DESC;

-- Count rows matching a condition
SELECT COUNT(*)
FROM Order
WHERE CustomerID = 5;

-- Select all columns
SELECT *
FROM Product
WHERE Price < 10.00;

Filtering operators: =, <> (not equal), <, >, <=, >=, LIKE (pattern matching with % wildcard), IN, BETWEEN … AND …, AND, OR, NOT.

JOIN: Combining Tables

JOIN combines rows from two or more tables based on a related column (usually a foreign key).

INNER JOIN

Returns rows where there is a match in both tables.

SELECT Student.Name, Course.Title
FROM Student
INNER JOIN Enrolment ON Student.StudentID = Enrolment.StudentID
INNER JOIN Course ON Enrolment.CourseCode = Course.CourseCode
WHERE Course.Title = 'Computer Science';

LEFT JOIN (LEFT OUTER JOIN)

Returns all rows from the left table and matched rows from the right; unmatched right-side values are NULL.

SELECT Customer.Name, Order.OrderID
FROM Customer
LEFT JOIN Order ON Customer.CustomerID = Order.CustomerID;
-- Returns all customers, even those with no orders (OrderID = NULL)

When to use each:

  • INNER JOIN: only records that have matching data in both tables
  • LEFT JOIN: all records from the left table, whether or not they have matches

INSERT, UPDATE, DELETE

INSERT INTO

Adds a new row to a table.

INSERT INTO Student (StudentID, Name, Email, Grade)
VALUES (42, 'Alice', 'alice@school.ac.uk', 85);

UPDATE … SET

Modifies existing rows. Without a WHERE clause, all rows are updated.

UPDATE Product
SET Price = Price * 1.1
WHERE Category = 'Electronics';

DELETE FROM

Removes rows. Without a WHERE clause, all rows are deleted.

DELETE FROM Order
WHERE OrderDate < '2024-01-01';

Caution: UPDATE and DELETE without WHERE affect every row in the table.

CREATE TABLE (DDL)

DDL (Data Definition Language) defines the structure of a database.

CREATE TABLE Student (
    StudentID   INTEGER     PRIMARY KEY,
    Name        VARCHAR(50) NOT NULL,
    Email       VARCHAR(100) UNIQUE,
    Grade       INTEGER,
    CourseCode  CHAR(6)     REFERENCES Course(CourseCode)
);

Key constraints:

ConstraintMeaning
PRIMARY KEYUniquely identifies each row; cannot be NULL
NOT NULLThe column must have a value
UNIQUEAll values in the column must be distinct
REFERENCES Table(Column)Foreign key — enforces referential integrity
CHECK (condition)Validates column values against a condition

Something not quite clicking?

Ask Aica to explain any part of this differently. Free, takes 30 seconds.

Ask Aica

Client-Server Databases and Concurrent Access

A client-server database allows multiple clients to access and modify the database simultaneously. This introduces a fundamental problem: concurrent access.

The lost update problem

Two clients read the same value and both update it — the second update overwrites the first, losing a change.

Client A reads StockLevel = 10
Client B reads StockLevel = 10
Client A writes StockLevel = 9  (deducts 1)
Client B writes StockLevel = 8  (deducts 2 from the original 10 — Client A's update is lost)
Result: StockLevel = 8, but should be 7

Concurrency control methods

Record locking: a client locks a record when reading it for update; other clients must wait until the lock is released.

Serialisation: transactions are scheduled so they execute as if they ran sequentially, even if they run concurrently. Guarantees consistent results.

Timestamp ordering: each transaction is assigned a timestamp when it starts. Conflicting operations are resolved in timestamp order — older transactions take priority.

Commitment ordering: transactions are committed in an order that respects their dependencies, preventing cycles.

Common Exam Mistakes

1. Forgetting the WHERE clause in UPDATE and DELETE

UPDATE Product SET Price = 0; sets every product's price to 0. DELETE FROM Student; deletes every student. These are valid SQL that run without error — the missing WHERE clause is a logic error, not a syntax error.

2. Confusing INNER JOIN and LEFT JOIN

INNER JOIN returns only matched rows — customers with no orders are excluded. LEFT JOIN returns all customers, with NULL for the order columns when there is no match. The choice depends on whether you want unmatched rows.

3. Confusing DDL and DML

DDL (Data Definition Language): CREATE TABLE, ALTER TABLE, DROP TABLE — define structure. DML (Data Manipulation Language): SELECT, INSERT, UPDATE, DELETE — manipulate data. Exam questions sometimes ask which category a statement belongs to.

4. Describing record locking without mentioning deadlock risk

Record locking solves the lost update problem but creates a deadlock risk: Client A holds lock on Record 1 and waits for Record 2; Client B holds lock on Record 2 and waits for Record 1. Neither can proceed. Database systems use timeout detection or deadlock detection algorithms to resolve this.

Key terms

SELECT
An SQL statement that retrieves data from one or more tables, optionally filtered with WHERE and sorted with ORDER BY.
JOIN
An SQL operation that combines rows from two or more tables based on a related column, usually a foreign key.
INNER JOIN
A join that returns only the rows where there is a match in both tables.
LEFT JOIN
A join that returns all rows from the left table plus matched rows from the right, with NULL for unmatched right-side values.
DDL
Data Definition Language: SQL statements such as CREATE TABLE, ALTER TABLE and DROP TABLE that define the structure of a database.
DML
Data Manipulation Language: SQL statements such as SELECT, INSERT, UPDATE and DELETE that manipulate the data in a database.
Primary key
A constraint that uniquely identifies each row in a table and cannot be NULL.
Foreign key
A column that references a key in another table (REFERENCES Table(Column)), enforcing referential integrity.
Client-server database
A database that allows multiple clients to access and modify it simultaneously, which introduces the problem of concurrent access.
Record locking
A concurrency control method where a client locks a record when reading it for update, forcing other clients to wait until the lock is released.
Serialisation
A concurrency control method that schedules transactions so they execute as if run sequentially, guaranteeing consistent results.
Deadlock
A situation where two clients each hold a lock the other needs and neither can proceed; databases use timeout or deadlock detection to resolve it.

Frequently asked questions

INNER JOIN returns only rows that have a match in both tables, so unmatched rows are excluded. LEFT JOIN returns all rows from the left table and matched rows from the right, putting NULL in the right-side columns where there is no match.

Every row in the table is affected. UPDATE Product SET Price = 0 sets every product's price to 0, and DELETE FROM Student deletes every student. These run without error, so the missing WHERE clause is a logic error, not a syntax error.

It occurs when two clients read the same value and both update it, so the second write overwrites the first and a change is lost. Record locking, serialisation, timestamp ordering or commitment ordering are used to prevent it.

Generate revision on any topic you study

Type any topic you're studying and Aicademy generates a complete lesson, quiz, and flashcard set, personalised to your level.

Lessons on anything

Structured, level-matched lessons on any topic you study

Practice quizzes

Find out what you actually know before the exam does

Flashcard sets

Lock in key concepts with instant revision cards

Ask Aica

Stuck on something? Get a clear explanation, any time

Prev

Database Normalisation

Related lessons

Top students don’t revise more. They revise what counts.

Start revising free

Free to start. No card needed.