Relational databases — AQA A-Level Computer Science
A relational database organises data into structured tables (relations) comprising records (tuples) and fields (attributes), linked together using primary and foreign keys. Mastering database design requires applying normalization up to third normal form (3NF) and writing precise SQL queries to guarantee data integrity and reduce redundancy.
Relational databases explained
A relational database stores data in one or more tables, where each table holds data about a single type of entity and each row represents one instance of that entity.
Read the full explanation
Columns, called attributes or fields, hold the individual pieces of data for each row. Tables are linked to one another through keys: a primary key uniquely identifies each row within its table, and a foreign key is an attribute in one table that refers to the primary key of another table. This linking allows related data to be combined when queried, without repeating the same data in many places. For example, a Customers table and an Orders table can be linked by a CustomerID, so an order records which customer placed it. Explaining the concept means describing tables, rows, columns, and the keys that relate tables together.
Your focus
- Explain the concept of a relational database.
Which command word is this?
Set out the reasons or mechanisms behind a database concept clearly. For example, explaining why a table is not in 3NF requires naming the specific transitive dependency and the columns involved.
Relational databases exam tips
Topic Overview
Relational databases provide an organised, robust architecture for persisting and managing structured data across multiple connected entities. By enforcing relationships via primary and foreign keys, relational databases minimise data redundancy and maintain referential integrity.
For AQA A-Level Computer Science, students must master conceptual modelling using Entity-Relationship Diagrams (ERDs), mathematical normalization from unnormalised form (UNF) through to 3NF, and practical manipulation using both Data Definition Language (DDL) and Data Manipulation Language (DML) in SQL.
Key Concepts
- →Relational Model Structure: Relations (tables), attributes (columns), and tuples (rows or records), where each attribute must hold atomic values.
- →Keys and Referential Integrity: Primary keys uniquely identify tuples; foreign keys establish links between relations and must match a valid primary key in the referenced relation.
- →Normalization (1NF, 2NF, 3NF): Systematic progressive elimination of repeating groups (1NF), partial key dependencies (2NF), and non-key transitive dependencies (3NF).
- →Structured Query Language (SQL): Declarative language dividing into DDL (CREATE, ALTER, DROP) and DML (SELECT, INSERT, UPDATE, DELETE) with complex filtering and joins.
Marking Points
- Explains that data is stored in tables, each representing one type of entity
- Explains that rows represent individual instances and columns represent attributes
- Explains that tables are related to each other using keys
- Explains that linking tables avoids repeating the same data
Examiner Tips
- 💡Define a table, a row and a column before explaining how tables are linked.
- 💡Give a concrete example of two tables linked by a key to show the concept.
- 💡Explain why linking tables avoids repeated data rather than just stating that it does.
- 💡When drawing or interpreting Entity-Relationship Diagrams (ERDs), always resolve many-to-many (M:N) relationships into two one-to-many (1:M) relationships using an associative link entity.
- 💡Underline primary keys and prefix foreign keys with an asterisk or hash, explicitly declaring the notation used if the exam question does not specify a convention.
- 💡In SQL questions, check whether the prompt asks for specific table aliases or fully qualified column names (e.g. Customer.CustomerID) to avoid ambiguity during table joins.
Common Mistakes
- Describes a relational database as just a collection of files; the key idea is that tables are related through keys.
- Describes a table as a single record instead of a set of rows that each hold one instance of the entity.
- Omits the role of keys in linking tables, giving a description of storage only.
- Thinking 2NF issues can occur in tables with a single-attribute primary key. Partial dependencies only exist when there is a composite primary key.
- Assuming that normalizing a database always improves query speed. While normalization eliminates update/insert/delete anomalies and reduces redundancy, it often requires more JOIN operations, which can decrease read performance.
- Confusing the WHERE clause with the HAVING clause in SQL: WHERE filters individual records before aggregation, whereas HAVING filters grouped data after a GROUP BY operation.
Revision Plan
- 1Day 1-2: Master Entity-Relationship Diagrams (ERDs), entity cardinality (1:1, 1:M, M:N), and resolving M:N links with associative junction entities.
- 2Day 3-5: Practice Normalization step-by-step with raw dataset tables: memorize definitions for 1NF, 2NF, and 3NF, and practice identifying partial vs transitive dependencies.
- 3Day 6-8: Write SQL DDL (CREATE TABLE with PRIMARY KEY, FOREIGN KEY constraints) and DML queries (SELECT ... WHERE ... ORDER BY, aggregates, and INNER JOINs).
- 4Day 9-10: Review transaction processing concepts (ACID properties, record locking) and complete timed AQA past-paper questions.
Exam Question Types
- 📋Normalization Scenario: Given a flat table or unnormalised form (UNF), produce relations in 3NF and annotate keys.
- 📋Entity-Relationship Modelling: Draw or complete an ER diagram based on a business scenario, resolving any many-to-many relationships.
- 📋SQL Query Writing: Construct DDL statements to build tables with constraints, or DML statements using SELECT with WHERE, GROUP BY, HAVING, or INNER JOIN.
- 📋Theory of Transaction Processing & DBMS: Discuss referential integrity, record locking, or how ACID properties ensure database reliability during concurrent access.
Command Word Expectations (AQA)
Set out the reasons or mechanisms behind a database concept clearly. For example, explaining why a table is not in 3NF requires naming the specific transitive dependency and the columns involved.
Provide formal relation schemas with table names, bracketed attributes, and explicit notation indicating primary and foreign keys (e.g., TableName(*PrimaryKey, #ForeignKey, Attribute)).
Produce syntactically valid SQL code adhering to standard SQL conventions, including correct keywords, clauses in standard order, and appropriate join conditions.
How Students Lose Marks (Examiner Pitfalls)
Step-by-Step Worked Solutions
Question: A school stores data about musical instrument lessons in an unnormalised format: Lesson(StudentNumber, StudentName, Instrument, TeacherID, TeacherName, TeacherRoom) Each student can learn multiple instruments. Each instrument has only one dedicated teacher, and each teacher has their own room. Explain why this relation is not in 3NF and normalise it into 3NF relations, clearly denoting primary keys with an asterisk (*) and foreign keys with a hash (#).
- 1.Step 1: Check 1NF: Assuming values are atomic and each record is distinct, the composite primary key must be (StudentNumber, Instrument) because a student can learn multiple instruments.
- 2.Step 2: Check 2NF: Identify partial dependencies. StudentName depends only on StudentNumber (part of the composite key). TeacherID, TeacherName, and TeacherRoom depend solely on Instrument. Therefore, the relation violates 2NF.
- 3.Step 3: Resolve to 2NF: Split into Student(*StudentNumber, StudentName), InstrumentTeacher(*Instrument, TeacherID, TeacherName, TeacherRoom), and LessonLink(*#StudentNumber, *#Instrument).
- 4.Step 4: Check 3NF: In InstrumentTeacher, TeacherName and TeacherRoom depend functionally on TeacherID, which is a non-key attribute (transitive dependency: Instrument -> TeacherID -> TeacherName, TeacherRoom).
- 5.Step 5: Resolve to 3NF: Split the teacher details into a separate Teacher relation: Teacher(*TeacherID, TeacherName, TeacherRoom) and link Instrument to Teacher: Instrument(*Instrument, #TeacherID).
Question: Write an SQL query to retrieve the names of all students ('StudentName') and the instrument they play ('InstrumentName') who have lessons in room 'M12'. Use the following schema: Student(StudentID, StudentName) Lesson(LessonID, StudentID, TeacherID) Teacher(TeacherID, TeacherName, RoomNumber, InstrumentName)
- 1.Step 1: Identify required output fields: Student.StudentName and Teacher.InstrumentName.
- 2.Step 2: Identify tables involved: Student, Lesson, and Teacher.
- 3.Step 3: Formulate join predicates: Student.StudentID = Lesson.StudentID and Lesson.TeacherID = Teacher.TeacherID.
- 4.Step 4: Add the WHERE condition: Teacher.RoomNumber = 'M12'.