Skip to topic
    ← Back to course topics

    Fundamentals of databases — AQA A-Level Computer Science

    Test yourself on Fundamentals of databases with AQA A-Level practice questions.

    Start free

    7 days Premium · Then free forever · No card, no charge

    Fundamentals of databases explained

    Structured Query Language (SQL) is the standard language for interacting with relational databases, enabling users to retrieve, insert, update, and delete data efficiently.

    Read the full explanation

    Mastery of commands such as SELECT, JOIN, GROUP BY, and HAVING is essential for extracting valuable insights from data and forms a core competency in database management and application development. This subtopic emphasizes practical query construction and data manipulation techniques that are fundamental to real-world database systems.

    Your focus

    1. Construct SQL SELECT queries to retrieve specified data from single and multiple tables using appropriate filtering and sorting.
    2. Apply INSERT, UPDATE, and DELETE statements to modify database contents while maintaining data integrity.
    3. Design queries using various JOIN types (e.g., INNER, LEFT, RIGHT) to integrate related data from multiple tables.
    Show all 6 objectives
    1. Implement GROUP BY clauses with aggregate functions to summarize data at different levels of granularity.
    2. Differentiate between WHERE and HAVING clauses to correctly filter rows before and after grouping.
    3. Analyze SQL query outputs to verify correctness and identify potential errors in logic or syntax.

    Fundamentals of databases exam tips

    Topic Overview

    Databases are fundamental to modern computing, enabling efficient storage, retrieval, and management of large volumes of structured data. In the AQA A-Level Computer Science specification, this topic covers the principles of database design, the relational model, and the use of Structured Query Language (SQL) to manipulate data. You will learn how to design a database schema using entity-relationship (ER) diagrams, normalise data to reduce redundancy, and implement queries using SQL. Understanding databases is crucial for developing data-driven applications and is a core component of the course, often examined through both theoretical questions and practical SQL tasks.

    The relational database model organises data into tables (relations) with rows (tuples) and columns (attributes). Each table represents an entity, and relationships between entities are established through foreign keys. You will study the three normal forms (1NF, 2NF, 3NF) to ensure data integrity and eliminate anomalies. Additionally, you will learn about transactions, ACID properties (Atomicity, Consistency, Isolation, Durability), and the role of database management systems (DBMS). This knowledge is not only examinable but also directly applicable to real-world scenarios, such as designing a school's student records system or an e-commerce platform.

    Mastering databases is essential for any aspiring software developer or data analyst. The topic builds on earlier concepts of data structures and algorithms, and it connects to later topics like big data and data mining. In the A-Level exam, you may be asked to interpret a scenario, draw an ER diagram, normalise a set of attributes, write SQL queries, or discuss the advantages of using a DBMS. A strong grasp of databases will help you secure high marks in both Paper 1 (practical programming) and Paper 2 (theoretical concepts).

    Key Concepts
    • →Relational model: data organised into tables with rows and columns; primary keys uniquely identify each row; foreign keys link tables.
    • →Normalisation: process of organising data to reduce redundancy and dependency, typically up to Third Normal Form (3NF).
    • →SQL: standard language for querying and manipulating databases; includes SELECT, INSERT, UPDATE, DELETE, and JOIN operations.
    • →Entity-Relationship (ER) diagrams: graphical representation of entities, attributes, and relationships (one-to-one, one-to-many, many-to-many).
    • →ACID properties: ensure reliable processing of database transactions (Atomicity, Consistency, Isolation, Durability).
    Marking Points
    • Award credit for accurate SQL syntax, including correct capitalization of keywords, use of quotes for strings, and appropriate punctuation.
    • When using JOIN, award credit for specifying the correct ON condition linking primary and foreign keys; penalize Cartesian products.
    • In GROUP BY queries, require all non-aggregated columns in SELECT to appear in the GROUP BY clause; award credit for appropriate use of aggregate functions (e.g., COUNT, SUM, AVG).
    • For HAVING, award credit when it is correctly applied to filter groups (not individual rows), and distinguish from WHERE usage.
    • In data manipulation commands, award credit for WHERE clauses that accurately target specific rows; penalize unqualified DELETE/UPDATE that could cause data loss.
    Examiner Tips
    • 💡Always test your SQL queries on sample data before finalizing; predict the expected output to verify logic.
    • 💡Remember the standard SQL execution order: FROM → JOIN → WHERE → GROUP BY → HAVING → SELECT → ORDER BY.
    • 💡When working with GROUP BY, double-check that every column in the SELECT list is either in the GROUP BY clause or an argument to an aggregate function.
    • 💡Use aliases for table names in multi-table queries to improve readability and avoid ambiguity.
    • 💡When writing SQL queries, always specify the columns you need instead of using SELECT * to show you understand projection and to avoid unnecessary data retrieval.
    • 💡In ER diagrams, clearly label relationship cardinalities (1:1, 1:M, M:N) and ensure entities have appropriate attributes. Many-to-many relationships must be resolved into two one-to-many relationships using a linking table.
    • 💡For normalisation questions, start by identifying the primary key and functional dependencies. Check for partial dependencies (2NF) and transitive dependencies (3NF). Show your working step by step to gain method marks.
    Common Mistakes
    • Confusing WHERE and HAVING: applying HAVING for row-level filters rather than group-level filters.
    • Omitting GROUP BY for non-aggregated columns when using aggregate functions, leading to logical errors.
    • Incorrect JOIN conditions resulting in Cartesian products or mismatches; forgetting the ON clause.
    • Using DELETE or UPDATE without a WHERE clause, accidentally modifying or removing all rows.
    • Misunderstanding the order of SQL clause execution, leading to illogical queries (e.g., referencing aliases in WHERE before they are defined).
    • Misconception: A primary key can be NULL. Correction: A primary key must be unique and not NULL; it uniquely identifies each record.
    • Misconception: Normalisation always improves performance. Correction: Normalisation reduces redundancy but can increase the number of joins, which may slow down queries. Denormalisation is sometimes used for performance.
    • Misconception: SQL is case-insensitive for everything. Correction: SQL keywords are case-insensitive, but string comparisons are case-sensitive in many DBMS (e.g., MySQL depends on collation).
    Frequently Asked Questions
    What is the difference between a primary key and a foreign key?
    A primary key is a unique identifier for each record in a table; it must contain unique values and cannot be NULL. A foreign key is a field in one table that refers to the primary key of another table, establishing a link between the two tables. Foreign keys can have duplicate values and can be NULL, but they must match a primary key value in the referenced table (referential integrity).
    How do I normalise a database to 3NF?
    To normalise to 3NF, follow these steps: 1) Ensure the table is in 1NF (atomic values, no repeating groups). 2) Remove partial dependencies to achieve 2NF (all non-key attributes must depend on the whole primary key). 3) Remove transitive dependencies to achieve 3NF (non-key attributes should not depend on other non-key attributes). For example, in a table with StudentID, CourseID, InstructorName, if InstructorName depends on CourseID (not StudentID), you would split into separate tables for Students, Courses, and Instructors.
    What SQL command do I use to join two tables?
    The SQL command to join two tables is JOIN, typically an INNER JOIN. For example: SELECT * FROM Students INNER JOIN Enrolments ON Students.StudentID = Enrolments.StudentID; This returns rows where there is a match in both tables. You can also use LEFT JOIN, RIGHT JOIN, or FULL OUTER JOIN depending on the desired result. Always specify the join condition using ON.
    Why is normalisation important?
    Normalisation reduces data redundancy and improves data integrity. By organising data into separate tables and eliminating duplicate information, you avoid update anomalies (e.g., updating a student's address in multiple places), insertion anomalies (e.g., unable to add a new course without a student), and deletion anomalies (e.g., losing course information when deleting a student). It also makes the database more flexible and easier to maintain.
    What are ACID properties in databases?
    ACID stands for Atomicity, Consistency, Isolation, and Durability. Atomicity ensures that a transaction is all-or-nothing; if any part fails, the entire transaction is rolled back. Consistency ensures that a transaction brings the database from one valid state to another, maintaining all rules (e.g., constraints). Isolation ensures that concurrent transactions do not interfere with each other. Durability guarantees that once a transaction is committed, it remains permanent even in case of a system failure.
    How do I draw an ER diagram for a school database?
    First, identify entities: e.g., Student, Teacher, Course, Classroom. Define attributes for each entity (e.g., Student: StudentID, Name, DateOfBirth). Determine relationships: e.g., a Student enrols in many Courses (many-to-many), so you need a linking entity Enrolment. A Teacher teaches one or more Courses (one-to-many). Use rectangles for entities, ovals for attributes, and diamonds for relationships. Label cardinalities (1, M, N) on the lines connecting entities.