AQA 8525 ยง3.7 (Databases)
๐Ÿ—„๏ธ Why Do We Need Relational Databases? (No More Duplicate Data!)

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.

๐Ÿ“ Tables & Records

A table holds records (rows) and fields (columns). Separating tables prevents data redundancy (unnecessary duplication).

๐Ÿ”‘ Primary vs Foreign Keys

Primary Key (PK): Unique ID in its own table.
Foreign Key (FK): Links back to the PK of another table to connect records.

๐Ÿ’ฌ The 4 AQA SQL Commands
SELECT (which columns) โ€ข FROM (which table)
WHERE (filter condition) โ€ข ORDER BY (sort ASC/DESC)
Schema

Relational Tables & Keys

PK = Primary Key FK = Foreign Key
๐Ÿ“ Students (Entity: Student Details) 7 records
StudentID PK FirstName LastName YearGroup FormGroup
๐Ÿ“ ExamResults (Entity: Assessment Scores) 8 records
ResultID PK StudentID FK Subject Grade Score
๐Ÿ”— Relationship: ExamResults.StudentID FK links to Students.StudentID PK (One student can have many exam results).
Query Editor

AQA SQL Builder

SELECT โ€ข FROM โ€ข WHERE โ€ข ORDER BY
โšก 1-Click Starter Queries: (Click any chip to run instantly)
Ready.
Output

Query Results

0 rows returned
Engine Tracer

Query Execution Plan

Step-by-Step

How the database engine parsed and executed your SQL statement:

AQA 8525 ยง3.7 Questions
Select Challenge:
WARM-UP [2 MARKS]

Challenge 1: Find All Year 11 Students

Table: Students

Write an SQL query to retrieve the FirstName and LastName of all students in YearGroup = 11 from the Students table.

Target Output Should Contain:
4 rows (Alice Smith, Bob Jones, Daisy Evans, Fiona White)
Write Your SQL Query:
AQA 8525 ยง3.7 Specification Focus

๐Ÿ“Œ Key Exam Traps & Core Concepts

AQA DEFINITION 1: RELATIONAL KEYS

Primary Key vs Foreign Key

Examiners frequently ask for definitions of primary and foreign keys. Be precise with your wording:

Primary Key (PK):
โ€ข A field (or attribute) that uniquely identifies each individual record in a table.
โ€ข Example: StudentID in the Students table.
Foreign Key (FK):
โ€ข 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.
โš ๏ธ Mark Scheme Tip: Never say a foreign key is just "a key in another table". You must state it is a primary key from one table placed into another to create a relationship.
AQA TRAP 2: DATA INTEGRITY

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."

โœ“ Reduces Data Redundancy: Data is not duplicated unnecessarily across multiple rows.
โœ“ 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.
AQA TRAP 3: SQL SYNTAX RULES

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.

โœ“ Correct: WHERE Subject = 'Computing' AND Score >= 80
โœ— Wrong: WHERE Subject = Computing AND Score >= '80'

๐Ÿ“ AQA Past Paper Style Questions with Mark Schemes

Databases โ€ข 1 Mark

Q1: Define what is meant by a foreign key in a relational database.

[1 mark] A primary key from one table that is included in another table to establish a link/relationship between the two tables.
Relational Design โ€ข 2 Marks

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.

[1 mark] Any one from: Prevents data redundancy / reduces duplication of student records.
[1 mark] Any one from: Avoids update anomalies / if student details change, they only need to be updated in one place (the Students table).
SQL Syntax โ€ข 3 Marks

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
[1 mark] SELECT Subject, Score FROM ExamResults
[1 mark] WHERE Score > 80
[1 mark] ORDER BY Score DESC