Imagine writing a student's full name, address, and form group next to every single exam they ever sit. If Alice takes 10 exams, her details would be repeated 10 times! If she moves house, updating 10 rows risks errors. In a Relational Database, we store student details once in the Students table, and link their exam results using a Foreign Key.
A table holds records (rows) and fields (columns). Separating tables prevents data redundancy (unnecessary duplication).
Primary Key (PK): Unique ID in its own table.
Foreign Key (FK): Links back to the PK of another table to connect records.
SELECT (which columns) โข FROM (which table)WHERE (filter condition) โข ORDER BY (sort ASC/DESC)
| StudentID PK | FirstName | LastName | YearGroup | FormGroup |
|---|
| ResultID PK | StudentID FK | Subject | Grade | Score |
|---|
ExamResults.StudentID FK links to Students.StudentID PK (One student can have many exam results).
How the database engine parsed and executed your SQL statement:
Write an SQL query to retrieve the FirstName and LastName of all students in YearGroup = 11 from the Students table.
๐ Key Exam Traps & Core Concepts
Primary Key vs Foreign Key
Examiners frequently ask for definitions of primary and foreign keys. Be precise with your wording:
โข A field (or attribute) that uniquely identifies each individual record in a table.
โข Example:
StudentID in the Students table.
โข An attribute in one table that is the primary key of another table, used to establish a link/relationship between the two tables.
โข Example:
ExamResults.StudentID.
Why Split Data into Multiple Tables? (Flat File vs Relational)
A classic 3-mark question: "Explain one advantage of using a relational database rather than a flat-file database."
โ Prevents Update Inconsistencies: If Alice changes form room, it is updated in one place only (in the Students table), rather than across 10 different exam entries.
โ Smaller File Size & Faster Queries: Less duplicate text means less storage used.
Quotes Around Strings vs Numbers
In SQL, text and character data types must always be wrapped in single quotes ('Computing' or '11A'). Numeric integers (such as Score >= 80 or YearGroup = 11) must not have quotes.
โ Wrong: WHERE Subject = Computing AND Score >= '80'
๐ AQA Past Paper Style Questions with Mark Schemes
Q1: Define what is meant by a foreign key in a relational database.
Q2: State two reasons why a school would use a relational database with separate Students and ExamResults tables rather than a single flat-file spreadsheet.
Q3: Write an SQL statement to retrieve the subject and score of all exam results from the ExamResults table where the score is greater than 80, ordered by score from highest to lowest.
SELECT Subject, Score FROM ExamResults
WHERE Score > 80
ORDER BY Score DESC