FoxChild@Learn
Year 7–9 | Databases | UK National Curriculum
A database is an organised, structured collection of data that enables efficient storage, retrieval, and management. Databases power virtually every digital system you interact with — from school administration systems to streaming services, social media platforms, and the NHS. This pack covers how databases are structured, the rules that keep data accurate, and the SQL language used to query them.
These terms are often used interchangeably but have distinct meanings:
| Example | Data | Information |
|---|---|---|
| A number | 17 |
"Student age: 17 years" |
| A series of digits | 07700900123 |
"Emergency contact phone number" |
| A word | "Red" |
"Traffic light status: Red — stop" |
A flat-file database stores all data in a single table (like a spreadsheet). Simple to create and understand for small datasets.
Problems with flat-file databases:
Example flat-file (showing redundancy problem):
| StudentID | StudentName | Subject | TeacherName | TeacherEmail |
|---|---|---|---|---|
| 101 | Alice | Computing | Mr Smith | smith@school.ac.uk |
| 102 | Bob | Computing | Mr Smith | smith@school.ac.uk |
| 103 | Charlie | Computing | Mr Smith | smith@school.ac.uk |
If Mr Smith leaves and Ms Jones takes over, three rows must all be updated. With 300 students, that is 300 changes — and missing even one causes an inconsistency.
A relational database splits data across multiple linked tables, each storing data about one type of entity. Tables are linked using keys.
Benefits:
| Feature | Flat-File | Relational |
|---|---|---|
| Number of tables | One | Multiple (linked) |
| Data redundancy | High — data repeated in many rows | Low — each fact stored once |
| Update anomalies | Common — must update many rows | Rare — update one record in one table |
| Consistency | Risk of inconsistency | High consistency |
| Complexity | Simple to understand | More complex to design |
| Scalability | Poor | Excellent |
A database is made up of tables. Each table stores data about one type of entity (e.g. Students, Teachers, Subjects).
Terminology:
| Term | Also called | Description | Example |
|---|---|---|---|
| Table | Relation | Grid of rows and columns storing data about one entity type | Students table |
| Field | Column / Attribute | A single category of data — one property of the entity | Name, Age, Subject |
| Record | Row / Tuple | One complete entry — all the data about one individual entity | Row for student Alice: 101, Alice, 15, Computing |
| StudentID | Name | Age | Subject | YearGroup |
|---|---|---|---|---|
| 101 | Alice | 15 | Computing | 10 |
| 102 | Bob | 14 | Computing | 9 |
| 103 | Charlie | 15 | Science | 10 |
| 104 | Diana | 13 | History | 8 |
| 105 | Ed | 14 | Computing | 9 |
StudentID is the primary keyThe primary key is the field (or combination of fields) that uniquely identifies each record in a table. Rules:
Why names cannot be primary keys: two students could have the same name (Alice Smith and Alice Jones). A primary key must be guaranteed unique — hence the use of generated IDs (StudentID: 101, 102, 103...).
Choosing a good primary key:
A foreign key is a field in one table that contains the primary key from another table, creating a link (relationship) between the two tables.
Example — linking Students to Teachers:
Students table:
| StudentID | Name | TeacherID |
|---|---|---|
| 101 | Alice | T01 |
| 102 | Bob | T01 |
| 103 | Charlie | T02 |
Teachers table:
| TeacherID | TeacherName | |
|---|---|---|
| T01 | Mr Smith | smith@school.ac.uk |
| T02 | Ms Jones | jones@school.ac.uk |
TeacherID in the Students table is a foreign key — it references the primary key (TeacherID) in the Teachers tableValidation is automated checking that data entered is acceptable, sensible, and within expected parameters. It is performed by the system before the data is stored.
Important: validation checks that data is reasonable — it does not guarantee the data is correct. A person could enter the wrong (but valid) date of birth.
| Validation Type | What It Checks | Example |
|---|---|---|
| Presence check | The field cannot be left empty | StudentID must not be blank |
| Range check | The value must be within a specified minimum and maximum | Age must be between 5 and 110 |
| Format check | The data must match a specified pattern | Date must be in format DD/MM/YYYY; postcode must match UK pattern |
| Type check | The data must be the correct data type | Age must be an integer, not text; price must be a decimal |
| Length check | The data must be within a specified character limit | Password must be 8–20 characters; name must not exceed 50 characters |
| Lookup check | The value must exist in a predefined list | Subject must be one of: Computing, Science, History, Geography, Maths |
Verification is checking that data has been entered accurately — that it matches the original source document exactly. This is a human-controlled process, unlike automated validation.
Verification methods:
| Method | How It Works |
|---|---|
| Double data entry | Data is entered twice (often by two different people); the system compares both entries and flags any differences |
| Proofreading | A human reads the entered data and compares it against the original document |
| Visual check | The data entry person checks the screen before submitting |
| Aspect | Validation | Verification |
|---|---|---|
| What it checks | Is the data reasonable/within rules? | Is the data an accurate copy of the source? |
| Who performs it | The computer system (automated) | A human (or double-entry system) |
| What it catches | Wrong data type, out-of-range, wrong format | Typos, transpositions, copying errors |
| Example | Age = -5 is rejected as out of range | A student's actual age is 15 but 51 was typed |
Can validation detect wrong-but-valid data? No. If a student is 15 but the user types 16 by mistake, range check (5–110) will accept 16 as valid. Only verification (proofreading) would catch this.
SQL (pronounced "sequel") is the standard language for interacting with relational databases. At KS3, you need to understand how to retrieve data using SELECT queries.
| Keyword | Purpose | Example |
|---|---|---|
SELECT |
Specifies which fields to display | SELECT Name, Age |
SELECT * |
Select ALL fields | SELECT * |
FROM |
Specifies which table to query | FROM Students |
WHERE |
Filters records to only show those matching a condition | WHERE Age > 14 |
ORDER BY |
Sorts results by a specified field | ORDER BY Name |
ASC |
Sort in ascending order (A→Z, 0→9) — default | ORDER BY Name ASC |
DESC |
Sort in descending order (Z→A, 9→0) | ORDER BY Age DESC |
AND |
Both conditions must be true | WHERE Age > 14 AND Subject = "Computing" |
OR |
At least one condition must be true | WHERE Subject = "Computing" OR Subject = "Science" |
SELECT field1, field2, field3
FROM TableName
WHERE condition1 AND/OR condition2
ORDER BY fieldName ASC/DESC;
SELECT Name, Age
FROM Students
WHERE Age > 14 AND Subject = "Computing"
ORDER BY Name ASC;
Line-by-line explanation:
SELECT Name, Age -- Show only the Name and Age columns (not StudentID, Subject, etc.)
FROM Students -- Look in the Students table
WHERE Age > 14 -- Only include records where Age is greater than 14...
AND Subject = "Computing" -- ...AND where Subject is exactly "Computing"
ORDER BY Name ASC; -- Sort the results alphabetically by Name (A first)
Applying this query to our sample table:
| StudentID | Name | Age | Subject | YearGroup |
|---|---|---|---|---|
| 101 | Alice | 15 | Computing | 10 |
| 102 | Bob | 14 | Computing | 9 |
| 103 | Charlie | 15 | Science | 10 |
| 104 | Diana | 13 | History | 8 |
| 105 | Ed | 14 | Computing | 9 |
Age > 14 — excludedSubject = "Computing" — excludedAge > 14 — excludedResult:
| Name | Age |
|---|---|
| Alice | 15 |
(Only Alice matches. If there were more Computing students over 14, they would be listed alphabetically.)
Select all students in Year 9:
SELECT *
FROM Students
WHERE YearGroup = 9;
Select names of students studying History or Geography, sorted by age (oldest first):
SELECT Name
FROM Students
WHERE Subject = "History" OR Subject = "Geography"
ORDER BY Age DESC;
Select all students under 15 in Year 8:
SELECT Name, Age, Subject
FROM Students
WHERE Age < 15 AND YearGroup = 8;
| Term | Definition |
|---|---|
| Data | Raw, unprocessed facts with no context |
| Information | Data given context and meaning so it can be interpreted |
| Database | An organised, structured collection of data |
| Flat-file database | All data in a single table; suffers from redundancy and update anomalies |
| Relational database | Data across multiple linked tables; reduces redundancy |
| Table | A grid of rows and columns storing data about one entity type |
| Field | A single column — one attribute or property of an entity |
| Record | A single row — all data about one entity |
| Primary key | Field that uniquely identifies each record; must be unique and not null |
| Foreign key | Field in one table holding the primary key of another table, creating a relationship |
| Data redundancy | The same data stored multiple times in different places |
| Update anomaly | Inconsistency caused by updating data in one place but not all places it is stored |
| Validation | Automated system check that entered data is acceptable/within rules |
| Verification | Human-based check that entered data accurately matches the source document |
| Presence check | Validation ensuring a field is not left empty |
| Range check | Validation ensuring a value is within specified minimum and maximum |
| Format check | Validation ensuring data matches a required pattern |
| Type check | Validation ensuring data is the correct data type |
| SQL | Structured Query Language — the standard language for querying relational databases |
| SELECT | SQL keyword specifying which fields to display |
| FROM | SQL keyword specifying which table to query |
| WHERE | SQL keyword filtering results to records matching a condition |
| ORDER BY | SQL keyword sorting results by a specified field |
| Misconception | Correction |
|---|---|
| "A database is just a spreadsheet" | A spreadsheet stores flat-file data in one sheet. A relational database has multiple linked tables, enforces data types, supports complex queries, handles millions of records efficiently, and includes primary/foreign key relationships. |
| "The primary key can repeat as long as most values are unique" | No. The primary key must be unique for EVERY record with no exceptions. Even one duplicate defeats the purpose — you can no longer uniquely identify a specific record. |
| "WHERE and ORDER BY do the same thing" | WHERE filters which records are included in the results. ORDER BY sorts the records that have already been selected. They are completely different operations. |
| "Validation proves the data is correct" | Validation only proves data is within acceptable parameters (e.g. age is between 5 and 110). It cannot detect errors that are within range — entering age 16 when the real age is 15 would pass validation. |
| "SQL can only be used to select/retrieve data" | SQL also includes commands for inserting new records (INSERT), updating existing records (UPDATE), deleting records (DELETE), and creating/modifying table structures (CREATE, ALTER, DROP). At KS3 we focus on SELECT. |
Q1 [2 marks] Explain what is meant by a primary key in a database table.
Q2 [2 marks] Describe one difference between validation and verification of data.
Q3 [3 marks]
Write an SQL query that selects the Name and Age of all students who are over 14 years old, sorted alphabetically by name. Use the Students table.
Q4 [4 marks]
Look at the Students table below.
| StudentID | Name | Age | Subject | YearGroup |
|---|---|---|---|---|
| 101 | Alice | 15 | Computing | 10 |
| 102 | Bob | 14 | Computing | 9 |
| 103 | Charlie | 15 | Science | 10 |
(a) Identify the primary key in this table. [1 mark]
(b) Identify one field that would benefit from a range check validation and explain what the range check would do. [2 marks]
(c) Identify one type of validation that would be applied to the StudentID field. [1 mark]
Q5 [6 marks] Compare flat-file databases with relational databases. Your answer should refer to:
MCQ Which SQL keyword is used to filter records in a query?
A) SELECT B) ORDER BY C) FROM D) WHERE
Fill in the blanks A __________ key uniquely identifies each record in a table. A __________ key in one table links to the primary key in another table, creating a relationship. __________ validation checks that a field is not left empty. In SQL, the __________ keyword is used to specify which table to search, and the __________ keyword sorts the results.
Q1: A primary key is a field in a database table that uniquely identifies each record (1). No two records in the table can have the same primary key value, and the field cannot be empty/null (1). [2 marks]
Q2: Validation is an automated system check that data is within acceptable rules/parameters (e.g. checking a number is within a given range) (1). Verification is checking that the data entered is an accurate copy of the original source — typically done by a human (e.g. proofreading or double data entry) (1). [2 marks]
Q3:
SELECT Name, Age
FROM Students
WHERE Age > 14
ORDER BY Name ASC;
Award marks for: correct SELECT fields (1), correct WHERE condition (1), correct ORDER BY (1). Penalise but do not withhold all marks for minor syntax issues if intent is clear. [3 marks]
Q4:
(a) StudentID — it is unique for every student and identifies each record. [1 mark]
(b) Age — a range check would ensure that the age entered is between a sensible minimum (e.g. 11) and maximum (e.g. 18 for a school context), rejecting values like -5 or 200 as impossible. [2 marks: 1 for identifying field, 1 for explaining what the check does]
(c) Presence check (the StudentID cannot be empty/null) OR type check (must be an integer). [1 mark]
Q5: Award 1 mark per valid point, up to 6 marks:
MCQ: D — WHERE
Fill in the blanks: primary / foreign / Presence / FROM / ORDER BY