Revision Notes
OxfordAQA A-Level Computer Science (9645): Relational databases – Revision Notes
Recall notes for OxfordAQA 9645 sub-topic 3.15.1: ER models, keys, normalisation to 3NF, SQL commands and functions, lost updates and record locks.
- Subject
- Computer Science
- Level
- A LEVEL
- Topic
- Topic 15 – Databases
- Author
- Marlbridge Academic Team
- Updated
- Reviewed by
- Harris Khan (what this means)
Aligned to OxfordAQA A Level Computer Science (9645), 2024-onwards. Official specification .
Syllabus page (what it covers and how it is assessed): OxfordAQA A Level Computer Science.
Syllabus points this page covers
9645 (A Level)
- 3.15.1 Relational databases
This page covers 1 of the 2 subtopics in topic 15, Databases.
Found an error? Report a correction.
Need help with this topic? Request a free trial class for A Level Computer Science (9645).
These notes condense sub-topic 3.15.1 Relational databases of OxfordAQA International AS and A-level Computer Science (9645), Version 1.1 (International A-level content in topic 3.15, examined in Unit 4). For worked examples, see the relational databases study guide, then practise with the relational databases practice questions.
What the specification requires
- 3.15.1.1 Produce a data model from given requirements for a scenario with several entities; produce entity relationship diagrams and entity descriptions in the form Entity1(Attribute1, Attribute2, …).
- 3.15.1.2 Explain a relational database; define attribute/field, entity identifier/primary key, composite primary key, foreign key and relation/table.
- 3.15.1.3 Normalise relations to third normal form and know why databases are normalised.
- 3.15.1.4 Use SQL to retrieve, update, insert and delete data from several tables; use aggregate functions; define a table, with a primary key and a simple foreign key.
- 3.15.1.5 Client server databases, concurrent access, the lost update problem and record locks.
Key terms
| Abstract term | Implemented term | Meaning |
|---|---|---|
| Relation | Table | Set of records about one entity |
| Attribute | Field | One property of an entity |
| Entity identifier | Primary key | Value unique for each record |
| Composite entity identifier | Composite primary key | Two or more attributes together unique |
| Foreign key | A field holding the primary key of another table |
ER models
- Write entities as Entity(Identifier, Attribute, …).
- Relationship degrees: one-to-many, many-to-one, one-to-one, many-to-many.
- The foreign key goes on the many side of a one-to-many relationship.
- Many-to-many cannot be stored directly: add a link entity whose key contains both identifiers or has its own, giving two one-to-many relationships.
Bike hire model: Customer(CustomerID, Name, Phone), Bike(BikeID, BikeType, DailyRate), Hire(HireID, CustomerID, BikeID, StartDate, Days). Customer to Bike is many-to-many; Hire is the link.
Normalisation
- Why: to avoid redundancy and the update, insertion and deletion anomalies it causes.
- 3NF: every non-key attribute depends on the key, the whole key, and nothing but the key.
| Problem in the table | Fix |
|---|---|
| Attribute depends on only part of a composite key | Move it to a table keyed by that part |
| Non-key attribute depends on another non-key attribute | Move both to a new table keyed by the determining attribute |
| Repeated groups of attributes | Put them in their own rows or table |
Example: HireLog(HireID, CustomerID, CustomerName, Phone, BikeID, BikeType, DailyRate, StartDate, Days) splits into Customer, Bike and Hire.
SQL reminders
SELECT Name, BikeType, Days
FROM Customer, Hire, Bike
WHERE Customer.CustomerID = Hire.CustomerID
AND Hire.BikeID = Bike.BikeID
AND Days >= 3
ORDER BY Days DESC, Name;
| Command or function | Purpose |
|---|---|
| SELECT … FROM … WHERE | choose columns, tables and conditions |
| ORDER BY | sort (DESC for descending) |
| GROUP BY | one row per group, used with aggregates |
| COUNT, SUM, AVG, MIN, MAX | aggregate functions |
| UPDATE … SET … WHERE | change data |
| INSERT INTO … VALUES | add a record |
| DELETE FROM … WHERE | remove records |
| CREATE TABLE | define a table, data types, PRIMARY KEY, FOREIGN KEY |
- Match each foreign key to its primary key in WHERE when using several tables.
- Always add WHERE to UPDATE and DELETE.
- Results for the bike hire data: hires per type are Mountain 2, Road 3, Tandem 1; total spend is Ayesha Khan 129.00, Ben Ortiz 145.00, Chloe Mensah 72.00; the 6 hires have average 2.83 days (total 17).
CREATE TABLE Hire (
HireID INTEGER PRIMARY KEY,
CustomerID INTEGER,
BikeID INTEGER,
StartDate DATE,
Days INTEGER,
FOREIGN KEY (CustomerID) REFERENCES Customer(CustomerID)
);
Client server databases
- Concurrent access: many clients use the database at the same time.
- Lost update: two clients read the same value, both change it, and the second save overwrites the first.
- Record lock: a client that is changing a record locks it; others must wait until it is saved and unlocked.
| Step | Without locks | With locks |
|---|---|---|
| Stock is 10; A sells 3, B sells 2 | A and B both read 10 | A locks and reads 10 |
| A writes 7 | B must wait | |
| B writes 8 (A’s update lost) | A writes 7 and unlocks | |
| Final value | 8 (wrong) | B reads 7 and writes 5 (correct) |
Exam traps
- Many-to-many must be broken down with a link entity.
- Foreign key placement: on the many side.
- 3NF wording: key, whole key, and nothing but the key.
- Join conditions: forgetting them pairs every row with every other row.
- GROUP BY: use it with an aggregate; each selected plain field must be grouped.
- Locks cost time: waiting is the price of integrity.
- Terms: use attribute/entity identifier for models, field/primary key for implemented databases.
Quick self-test
- What is a foreign key?
- What is a composite primary key?
- How is a many-to-many relationship stored?
- State one anomaly caused by redundancy.
- State the three parts of the 3NF rule.
- Which SQL clause sorts results?
- Write an aggregate function that gives the number of rows.
- What does
DELETE FROM Hirewith no WHERE do? - What is concurrent access?
- What is the lost update problem?
- How does a record lock prevent it?
- For stock 10, A sells 3 and B sells 2 with locks. What is the final stock?
Answers
- A field that holds the primary key value of a record in another table.
- A primary key made of two or more fields that together are unique.
- With a link table (entity) that has one-to-many relationships to the two original tables.
- Update, insertion or deletion anomaly.
- Depends on the key, the whole key, and nothing but the key.
- ORDER BY.
- COUNT(*)
- It deletes every row in the table.
- Many clients using the database at the same time.
- Two clients change the same record from the same old value and the second save overwrites the first.
- It stops other clients updating the record until the first client has saved and released the lock.
-
Official syllabus
OxfordAQA International AS and A-level Computer Science (9645) specification, Version 1.1, for International AS exams May/June 2025 onwards and International A-level exams May/June 2026 onwards: sub-topic 3.15.1 Relational databases.
Related resources
-
Study guides
OxfordAQA A-Level Computer Science (9645): Big data
OxfordAQA 9645 sub-topic 3.15.2 in depth: volume, velocity and variety, distributed processing, functional programming and map-reduce, fact-based models and graph schemas.
Computer Science · OxfordAQA · A Level
Read guide -
Practice questions
OxfordAQA A-Level Computer Science (9645): Big data – Practice Questions
Ten original OxfordAQA 9645 questions on sub-topic 3.15.2 Big data: the three Vs, distributed processing, map-reduce, fact-based models and graph schemas.
Computer Science · OxfordAQA · A Level
Try questions -
Revision notes
OxfordAQA A-Level Computer Science (9645): Big data – Revision Notes
Recall notes for OxfordAQA 9645 sub-topic 3.15.2: the three Vs, distributed processing, functional programming, map-reduce, fact-based models and graph schemas.
Computer Science · OxfordAQA · A Level
Revise topic
Get free revision emails (optional)
Occasional emails with practice questions, worked explanations and links to free resources for the qualification and subjects you choose. No spam, and you can unsubscribe from any email. The free tools on this site never need an email.