GCSE · Computer Science · AQA · Spec 8525
What is a relational database
Picture one customer with two different addresses in the same shop's records. Nobody typed it on purpose. Let's see how database designers stop it from ever happening.
Computer Science · Databases
Layers
Explore
Tap each part to find out what it does. Switch the link off and you are left with two separate tables.
The link is not a drawing trick: it is two matching values, one in each table.
Customers on top, Orders underneath. Tap the parts, then try the link layer.
Your turn
What job does this field do?
Sort each field of the Customers and Orders tables by the job it does in its own table.
Still to sort
Primary key (0)
Different on every record of its own table.
Where the line is: A repeated value cannot be the primary key of its table, however useful it is.
Foreign key (0)
Holds primary key values from another table.
Where the line is: It points at records in another table, so its values can come up again and again in this one.
Ordinary field (0)
Just a detail about the record.
Where the line is: Neither identifies the record nor holds another table's key.
Same two tables as above. Pick a field, then drop it where it belongs.
Predict, then check
Now take the same shop and squash it into one big table. Think first.
In one big table, Ben Ortiz's address (9 Park Lane) is typed on both of his orders, 5001 and 5003. Ben moves to 21 Hill Street, and someone updates the address on order 5001 only. What does the database now say Ben's address is?
AQA GCSE Computer Science (8525): relational databases are in specification section 3.7.1. Computer Science isn't tiered, so this is for everyone.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
One table per type of thing, joined by keys, so every fact lives in one place.
What you need to know
- A relational database uses more than one table, each about one type of entity: a customer, say, or an order.
- Each row of a table is a record, and each column is a field.
- Tables are linked, or related, through fields they have in common.
Have a goA school has a Pupils table (PupilID, Name) and a Clubs table (ClubID, ClubName). As they stand, could these two tables be linked? Say why.
No. They have no field in common.
Tables are linked through fields they have in common, and these two share none yet.
- Primary key: a field whose value uniquely identifies each record in its table, so no two records share one.
Have a goYour classmate says: 'Name makes a perfect primary key. Everybody has one!' Then two pupils turn out to be called Sam Lee. What goes wrong?
Two records would share the same primary key value.
Having a value isn't enough. A primary key has to be different for every record in its table, and two Sam Lees would clash.
- Foreign key: a field in one table that holds the primary key value of a record in another table.
- Matching foreign key values to primary key values is what links records across the two tables.
Have a goThree records in a Bookings table each hold the foreign key value 7. How many records in the Members table do they point to?
One: the Members record whose primary key is 7.
A primary key value is unique in its own table, so a matching value can only land on one record. Many bookings can share a member.
- Splitting data into linked tables reduces data redundancy: each fact is stored once, not repeated in many records.
- Less redundancy helps avoid data inconsistency: change a fact in one place and different copies can't disagree.
The big picture
A relational database stores data in more than one linked table, one for each type of thing. A primary key identifies each record in its table, a foreign key holds another table's primary key values to link the tables, and storing each fact once reduces redundancy and helps avoid inconsistency.
Key points
Worked example
Problem
Practice question: A vet's surgery stores its data in two linked tables. Owners has the fields OwnerID and OwnerName, with the records (1, Ms Green) and (2, Mr Patel). Pets has the fields PetID, PetName and OwnerID, with the records (31, Biscuit, 2), (32, Mango, 1) and (33, Pip, 2). (a) Which field is the primary key of Pets? (b) Which field in Pets is a foreign key? (c) Who owns Pip?
⚠ Watch out
Thinking the field both tables share is a primary key in both. In a link like this it is the primary key in one table (a different value on every record) and a foreign key in the other (holding those values).
Memory hook
One table per thing. Keys do the linking. Store it once, change it once.
Check yourself
Cover the page. Invent a Teachers table and a Classes table, two or three records each. Mark each primary key, add a foreign key to Classes, and say which Teachers values it holds.
Flashcards
(8)What is a relational database?
What is an entity in a database design?
What does the link between two tables actually consist of?
What is a primary key?
What is a foreign key?
A Loans table has a MemberID field whose values come from the Members table. Primary key or foreign key in Loans?
What is data redundancy?
What is data inconsistency, and how do linked tables help avoid it?
Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.
Learning with Lightbulb is opening soon
You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.
Keep me postedMore AQA GCSE Computer Science topics
How this lesson was checked. This AQA GCSE Computer Science (specification 8525)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 4 November 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.