S
Topic 9 Databases · Page 9.1–9.2

Foundations Lab

Database structure and the SQL you'll use with it. Fields, records, validation, data types and primary keys — the foundation for every query in the Querying and Aggregating Labs.

🧪 Exam Mode ON — recall from memory, then reveal

📚 Topic overview

Every organisation you interact with runs on a database. Your school stores your attendance in one. Your streaming service stores what you've watched in one. When you log into a website and it "remembers" you, that's a database being queried in the background.

Topic 9 splits into two skills: first, how to design a database so it stores data cleanly (this Foundations Lab), and second, how to question a database so you can get information back out (the Querying and Aggregating Labs). This first lab tackles the foundations — the structure that makes everything else possible, and the language you'll use to talk to it.

Prerequisites: none required. If you've met data types in Topic 8 (Programming), you'll notice the database types are slightly different — that's one of the things this lab locks in.

🎯 Learning objectives

Cambridge 0478 Topic 9 · Databases
Outcome 1 Define a single-table database from given data storage requirements — fields, records and validation.
Outcome 2 Suggest suitable basic data types: text/alphanumeric, character, Boolean, integer, real, date/time.
Outcome 3 Understand the purpose of a primary key and identify a suitable primary key for a table.
Outcome 4 (introduction) Know what SQL is and what it is used for. Reading, completing and writing SQL scripts, and identifying their output, are covered in the Querying and Aggregating Labs.

📖 Key terminology

TermMeaning
DatabaseAn organised collection of data. In this syllabus, always a single-table database.
TableA set of data about one type of object (e.g. students, books, storage units). Made up of fields and records.
FieldAn individual piece of data being stored — one column in the table (e.g. LastName, Price).
RecordAll the fields about one object — one row in the table (e.g. everything stored about Aarna Singh).
ValidationAutomatic checks that data entered into a field is sensible and follows set rules (e.g. a range check on Age).
Data typeThe characteristic of a piece of data that tells the database what it can hold.
Text (alphanumeric)A data type storing letters, digits, symbols or a mix (e.g. Sparkle, AB12). The syllabus calls it text/alphanumeric — use this database term, not the programming term STRING.
CharacterA data type storing exactly one letter, digit, or symbol (e.g. 'A').
IntegerA data type storing a whole number, no decimal point (e.g. 23).
RealA data type storing a number with a decimal point (e.g. 3.99).
BooleanA data type storing one of two values, usually True/False or Yes/No. Written without quotation marks.
Date/TimeA data type storing a date and/or a time value.
Primary keyA unique field in a database used to identify one specific record. No two records can share the same primary key value.
SQLStructured Query Language — a standard language used across most databases to interact with data.
SQL scriptThe SQL commands used to query a table. In this syllabus a script is usually one SELECT statement built from clauses such as SELECT, FROM, WHERE and ORDER BY.
QueryA request made to the database to return specific data.

In SQL, text values go in quotation marks ("China"). Numbers and Boolean values (TRUE, FALSE) do not.

🧠 Core theory

1. Anatomy of a single-table database

A database table is a grid. Every column is a field (one category of data). Every row is a record (one entry). That's it — that's the whole shape.

BookIDBookNameAuthor
B01The HobbitTolkien
B02MatildaDahl
B03CoralineGaiman
B04WonderPalacio
Columns = fields Rows = records

Sanity check: this table has 3 fields and 4 records. Read down for fields, across for records.

Exam trap: examiner reports have flagged students who reverse fields and records. See Common misconceptions below.

2. The six database data types

The syllabus lists six basic data types for databases. Learn what each one stores — and whether its values go in quotation marks when they appear in an SQL query.

Data typeWhat it storesExample valueQuotes in SQL?
Text (alphanumeric)Letters, digits and symbols, e.g. names, codes, addressesAmsterdamYes: "Amsterdam"
CharacterExactly one characterASee note below
IntegerWhole number, no decimal1566999No
RealNumber with a decimal point3.99No
BooleanOne of two values: TRUE/FALSE (or Yes/No)TRUENo — a common trap
Date/TimeA date and/or a time14/06/2025See note below

The quotes column looks ahead to WHERE clauses in the Querying Lab. Examiner reports have flagged missing quotation marks around text values (e.g. 2023).

📎 Useful background

Different database systems write character and date values in different ways (for example 'A' or "A", and #14/06/2025# or "2025-06-14"). If a question needs one, copy the style used in the question.

3. Primary keys — what makes a field "unique"

Part A — what a primary key IS. A primary key is a field whose value never repeats across records. It uniquely identifies exactly one record. Examples you'll meet in past papers: StorageID, Code, ContractNumber, BookID, StudentID.

Part B — how you CHOOSE a primary key. Ask of every field: "Could two records ever share this value?"

  • If yes → not a primary key. Names repeat. Colours repeat. Prices repeat.
  • If no field is naturally unique, the designer adds one — usually an ID field like ItemID or Code.
  • The primary key is a column in the table, not a row and not the table's heading.

🗝️ Key phrase to learn

"…because it is a unique identifier." An answer that says the field is unique and that it identifies each record is the safest way to explain why a field is the primary key.

4. Validation in a database

When you define a table, you can add validation to a field. Validation checks that the data entered is sensible and follows set rules before it is stored. It cannot prove the data is correct — only that it is reasonable. These are the same checks you met in Topic 7:

CheckExample on a database field
Range checkAge must be between 11 and 18
Length checkCode must be exactly 4 characters
Type checkPopulation must be a whole number
Presence checkLastName cannot be left empty
Format checkCode must be two letters followed by two digits, e.g. AS01
Check digitThe last digit of an ISBN field is calculated from the other digits

Don't mix up: visual checks and double entry are verification (checking data was copied correctly), not validation.

5. What SQL is, and what this syllabus asks of it

SQL = Structured Query Language. It's the standard language across most database systems — learn it once, use it anywhere.

SQL can do many things: create tables, change them, add data, search data and calculate with it. This syllabus only uses SQL to query a single table, with these keywords: SELECT, FROM, WHERE, ORDER BY (ASCENDING / DESCENDING), SUM, COUNT, AND and OR.

An SQL script is the set of SQL commands you are given or asked to write. A query such as SELECT City FROM MajorCity WHERE Capital = TRUE is one statement made of several clauses.

📋 What the exam will ask you to do

You won't be asked to write SQL that creates or changes a table. You will be asked to read, complete and write SQL scripts, and to identify the output a query gives. That's the Querying and Aggregating Labs.

✏️ Worked examples

Example 1 — Reading the anatomy of a table

The table (MajorCity, adapted from 2025 s25):

Code    City       Capital   Country          Population
ASY1    Beijing    TRUE      China            21,766,214
EUY3    Amsterdam  TRUE      Netherlands       1,174,025
EUN1    Frankfurt  FALSE     Germany             796,437

Q: How many fields? How many records?

A: 5 fields (Code, City, Capital, Country, Population). 3 records (each row = one city).

Why it matters: counting fields and records is a common question, and examiner reports have flagged students who swap the two numbers.

Example 2 — Choosing a primary key

Same table. Which field could be the primary key?

  • City? Only if no two cities ever share a name. Global databases have this problem — think "Springfield". Weak candidate.
  • Country? No — multiple cities per country in this table's shape. Instant fail.
  • Code? Every code is different (ASY1, EUY3, EUN1). Yes — this is the unique identifier.

Winning answer format

"Code is the primary key because it is a unique identifier / no two records share the same code."

Example 3 — Picking data types

FieldStoresData type
ItemName"Sparkle"Text
Colour"red"Text
Weight2Integer
Price3.99Real
InStockYes/NoBoolean
DateAdded2026-01-15Date/Time

Trap flag: students often write string instead of Text. The syllabus calls this database type text/alphanumeric — STRING is the programming data type from Topic 8.

Example 4 — Recognising SQL vs. non-SQL

Which of these three snippets is SQL?

Snippet A:  DECLARE x : INTEGER
Snippet B:  SELECT City FROM MajorCity
Snippet C:  IF Price > 5 THEN OUTPUT "Expensive"

A: Only B is SQL. A is Cambridge pseudocode (a variable declaration). C is Cambridge pseudocode (a selection statement).

Why it matters: SQL is a separate language from the pseudocode you already know. Mixing keywords is a common mistake.

⚠️ Common misconceptions

Trap 1 — Swapping fields and records

❌ Saying the table has 23 fields and 6 records (when it has 6 fields and 23 records).

Fields are the columns (categories of data). Records are the rows (each individual entry). Number of records = number of things you're storing. Number of fields = number of details about each thing.

Cited: 2025 s25 Q8(a) examiner report.

Trap 2 — Writing "string" instead of "Text"

❌ Giving string as a data type in a database question.

In programming (Topic 8) you learned about STRING. For databases the syllabus uses text/alphanumeric. They store the same kind of data, but in a database question write Text (or alphanumeric).

Cited: 2023 examiner report — "A common error seen was to give string instead of text."

Trap 3 — Picking a non-unique field as the primary key

❌ Saying Type or Name or Country is the primary key because it's the "most important" field.

The primary key isn't the most important field — it's the unique one. If any two records could share the same value in that field, it cannot be a primary key. Ask yourself: "Could two records ever have the same value here?" If yes, it's out.

Cited: 2024 w24 — "Most candidates understood that the data in the Type field was not unique for all records, so could not be the primary key."

Trap 4 — Confusing the table structure names

❌ Identifying "Field" as a primary key when "Field" is the column heading of the table.

Some past-paper tables include a helper column literally labelled "Field" that lists the field names. Students then circle "Field" as the primary key. The primary key is one of the actual data fields — not the label above them.

Cited: 2024 s24 Q9 — "Some candidates incorrectly identified 'Field' as a primary key, which was the heading of the table."

Trap 5 — Forgetting the "unique identifier" phrase

❌ Saying the primary key was chosen "because it's important" or "because it comes first".

The safest way to explain why a field is the primary key: it is a unique identifier. Say it is unique and that it identifies each record. "Important" or "first" does not explain anything.

Cited: 2024 s24 Q9(a)(ii) — mark scheme awards "unique identifier" phrasing.

Trap 6 — Treating SQL as pseudocode

❌ Mixing pseudocode keywords into an SQL statement (e.g. writing OUTPUT instead of SELECT, or using IF inside a query).

SQL is a separate language from Cambridge pseudocode. SQL keywords are SELECT, FROM, WHERE, ORDER BY (ASCENDING / DESCENDING), SUM, COUNT, AND, OR. Pseudocode keywords like OUTPUT, DECLARE, IF never appear in SQL. Never mix them.

Cited: 2023 w23 examiner report on SQL punctuation and keyword errors.

🎯 Cambridge exam focus

Key points that earn credit.

"Unique identifier." The safest answer for "Why is X the primary key?" — "Because it is a unique identifier (of a record)." Say unique and say identify.
Fields = columns, records = rows. If asked to count either, count carefully and sanity-check: "How many categories? How many entries?"
Write "Text", not "String". In a database question the data type for words is Text (the syllabus also says alphanumeric). STRING is the programming term.
Boolean values are unquoted. Capital = TRUE, never Capital = "TRUE".
Text values in WHERE are quoted. Country = "China" (double quotes in our examples). Missing quotes is a common mark loss.
Primary key is a field, not a heading. The primary key is a column inside the table's data — not the label at the top of a helper column called "Field".
SQL is a separate language. Never mix pseudocode (OUTPUT, DECLARE, IF) into an SQL statement.
Complete every clause. If a question says "complete the SQL script", you may need SELECT, FROM, WHERE and ORDER BY — in that order.
Validation ≠ verification. Range, length, type, presence, format and check digit are validation. Visual check and double entry are verification.

🧪 Quick knowledge check

Click each question to reveal the answer. 0 / 7 revealed

1. What's the difference between a field and a record?
A field is a column — one type of data being stored (e.g. LastName). A record is a row — all the fields belonging to one entity (e.g. everything stored about one person).
2. A database has 6 columns and 11 rows. How many fields and how many records?
6 fields and 11 records. Fields = columns, records = rows.
3. Give the correct database data type for storing a person's name.
Text. Not String — that's the programming term.
4. Which data type stores a value like TRUE or FALSE, and does it need quotation marks in SQL?
Boolean. It does not take quotation marks — Boolean values are written unquoted.
5. Explain what a primary key is and why databases need one.
A primary key is a unique field that identifies one specific record. Databases need one because it lets the system find, update, or reference a single record with certainty — no two records share the same primary key value.
6. What does SQL stand for and what are the two things this syllabus uses SQL for?
SQL stands for Structured Query Language. This syllabus uses SQL to query a single table: (1) searching for data (SELECT … WHERE) and (2) calculating totals and counts (SUM, COUNT).
7. Name two validation checks that could be used on a database field, with an example of each.
Any two, e.g. range check (Age between 11 and 18), presence check (LastName not left empty), length check (Code exactly 4 characters), type check (Population a whole number), format check, check digit.

✅ Ready for the next lab

You've locked in the structural language of databases — fields, records, validation, data types and primary keys — and you know what SQL is for. That's the whole foundation.

Next lab: 9.3–9.5 Querying Lab — where you write SQL to pull specific data out of a table.

🎓 Learn — walking-around understanding

Book Notes is the reference. Learn is the walk-through. If you're new to databases entirely, start here and go slow. If Book Notes already clicked, skim.

Concept 1 · A table is a grid, not a shape you have to memorise

Every single database table you'll ever see in this course looks the same: a header row of field names, then a stack of data rows. That's it. If you can read a spreadsheet, you can read a database table.

The two questions Cambridge cares about are: which piece is which?

  • A field is a category of information. "Everyone's last name" is a field. "Everyone's date of birth" is another field. Fields run top to bottom as columns.
  • A record is one specific entry. Everything stored about Aarna Singh is one record. Everything stored about the book Matilda is one record. Records run left to right as rows.

Trick for the counting question

Cambridge often gives you a table and asks "how many fields and how many records?" Point at the top row and count categories → that's fields. Then count everything below the header → that's records. Slow down — students who rush often swap the numbers.

Concept 2 · Data types tell the database what kind of thing lives in each field

When you design a table, you have to decide what kind of data each field holds. The syllabus lists six types. There's a specific vocabulary — and it doesn't quite match what you learned in programming.

🔤

Text (alphanumeric) — letters, digits, symbols or a mix (city names, addresses, codes).
Character — exactly one symbol (like a grade "A").

🔢

Integer — whole numbers (population, count in stock).
Real — numbers with decimals (price, weight, percentages).

✅

Boolean — a yes/no or true/false switch (in stock? capital city? paid?).

📅

Date/Time — for dates, times, or both.

Watch: in programming you say String. In databases you say Text. Same idea, different word — use Text in a database question.

Concept 3 · Primary key = one-of-a-kind field

Imagine your school has two students both called Alex Chen. If the register just says "Alex Chen was absent," which one? You need something unique — a Student ID. That's a primary key.

Every database table needs one field where no two records share the same value. That field is the primary key. It's how the database points at exactly one row when it needs to find, update, or delete something.

Sometimes a natural field works: ContractNumber, ISBN, StorageID. When nothing natural is unique, the designer adds one: ItemID, Code.

The habit to build

Whenever Cambridge asks "Why is X the primary key?", write: "Because it is a unique identifier — no two records share the same X." Say unique. Say identify. Every time.

Concept 4 · SQL is a different language on top of the table

Once you have a table, you need a way to talk to it. That language is SQL — Structured Query Language.

SQL is not pseudocode. It's not Python. It's its own thing — a small set of keywords used to ask a database questions. In this syllabus you'll only use SQL to search (find rows that match a rule) and calculate (add them up, count them).

The exam won't ask you to create a table with SQL, add rows with SQL, or delete anything. Your job in the Querying and Aggregating Labs is to read, complete and write SQL scripts, and to work out what they output.

Vocabulary: a query such as SELECT ... FROM ... WHERE ... ORDER BY is one statement made of several clauses. An SQL script is the set of SQL commands you read, complete or write.

Concept 5 · Validation keeps silly data out

When you design a table you decide the fields, their data types — and the rules each field must follow. Those rules are validation. If someone types an age of 150 into a school database, a range check rejects it before it is stored.

The checks are the ones you met in Topic 7: range, length, type, presence, format and check digit. Validation makes data sensible; it can't prove it is true (an age of 15 passes even if the student is really 14).

You've got Learn — head to Activities

Time to build a table yourself with the Table Architect. That's where fields, data types, and primary keys stop being definitions and become decisions.

🎮 Table Architect

Pick a scenario, add the fields you think it needs, choose a data type for each, and nominate a primary key. The Architect will check your work against the way Cambridge expects a well-formed table to look — and flag the traps if you fall into one.

🛠️ Design your table
Pick a primary key
👀 Live preview — 3 example records

Add some fields on the left. The preview will fill in as you go.

What the Architect is testing

  • Did you include the essential fields? Each scenario has fields Cambridge would expect. Miss too many and you'll get a "table is too thin" hint.
  • Are your data types right? A field storing a price is Real, not Integer. A field storing yes/no is Boolean, not Text.
  • Is your primary key actually unique? Names repeat. Types repeat. IDs and codes don't. The Architect will call it out if you pick a repeatable field.
  • Text, not String. The dropdown uses the database data type names from the syllabus, so you practise the right words.

⚡ 60-second sprint

Rapid-fire questions on foundations vocabulary. Sixty seconds on the clock. Beat your best score.

✎ Practice questions

Multiple-choice checks. Start on Easy if you're new to the topic; move up as you go. Every attempt is logged in Progress. Adaptive: weak skills come up more often.

All
Easy
Medium
Exam-style
🧪 Exam Mode
🧪 Exam Mode active. Options are hidden — recall the answer in your head, then reveal and self-mark.

📋 Exam-style questions

Written questions in the Paper 2 style. Type your answer, press Mark my answer, then compare it with the model answer. Skills feed into Mastery.

🔄 Review

Mark-losing traps that examiner reports have flagged on database structure and SQL basics — plus memory triggers for the key phrases.

⚠️ 10 traps to know

Read them before every mock exam.

Trap 1 · Swapping fields and records

Fields are columns (categories of data). Records are rows (individual entries). Students who rush swap the numbers under exam pressure.

Cited: 2025 s25 Q8(a) examiner report.

Trap 2 · Writing "String" instead of "Text"

In database questions the data type for words is Text (the syllabus says text/alphanumeric), not String. STRING is the programming data type from Topic 8.

Cited: 2023 examiner report — "A common error seen was to give string instead of text."

Trap 3 · Missing quotes around Text values in WHERE

Text values in WHERE clauses go in quotation marks: Country = "China". Missing quotes is a common way to lose the mark.

Cited: 2023 P2 Q9 examiner report — missing quotation marks around a text value.

Trap 4 · Adding quotes around Booleans or numbers

Booleans and numbers are not quoted in SQL: Capital = TRUE, Price > 5. Capital = "TRUE" compares the field with the text "TRUE", not the Boolean value.

Common exam mistake

Trap 5 · Vague primary key answers

The safest answer for "why is X the primary key?" is "because it is a unique identifier". Answers like "because it's important" or "because it's first" won't earn the mark.

Cited: 2025 s25 P2 Q8 MajorCity examiner report — model answer specifies "unique identifier".

Trap 6 · Choosing a repeatable field as the primary key

Names repeat. Prices repeat. Yes/No fields have only two values across the whole table. A primary key must be unique — usually an ID or Code field.

Common exam mistake

Trap 7 · Confusing primary key with the column header row

The primary key is a field — a column of data inside the table. It is NOT the label row at the top of a helper column called "Field". Read the question carefully.

Cited: 2024 s24 Q9 examiner report — "Field" (the table heading) identified as the primary key.

Trap 8 · Extra punctuation in SQL queries

Trailing commas after the last field (SELECT City, Country,), full stops instead of commas, or stray semicolons mid-query are all syntax errors. Cambridge flags "extra punctuation" as a recurring mark loss.

Cited: 2023 P2 examiner report — "A common error seen was to include extra punctuation."

Trap 9 · Extra punctuation in SQL output

When asked to "write the output of this SQL statement", students often add commas or full stops. Write plain values, one record per line, with no added punctuation.

Cited: 2024 w24 P2 — "Punctuation marks should not be in the output from an SQL statement." Reinforced 2025 m25 verbatim.

Trap 10 · Mixing pseudocode into SQL

SQL keywords are SELECT, FROM, WHERE, ORDER BY (ASCENDING / DESCENDING), SUM, COUNT, AND, OR. Pseudocode keywords like OUTPUT, DECLARE, IF never appear inside an SQL script. They're separate languages.

Cited: 2023 w23 P2 examiner report on SQL punctuation and keyword errors.

🧠 Memory triggers

Short mnemonics for the exam-critical phrases you'll be tested on.

🗝️ "R goes with R" — fields and records

Records = Rows, so fields = columns. "How many fields?" → count the column headings. "How many records?" → count the rows below the header.

🗝️ "Unique + identifies" — the primary key phrase

"Because it is a unique identifier." Say it is unique, and say it identifies each record.

🗝️ "TICRB-D" — the six data types

Text · Integer · Character · Real · Boolean · Date/Time. (Think: "Ticker-B-D".) That's every type in the syllabus list (Text is also called alphanumeric). No "String". No "Number". No "Letter".

🗝️ "Words in quotes"

The one-line rule: "Words go in quotes. Numbers and TRUE/FALSE don't." Country = "China", Population > 1000000, Capital = TRUE.

🗝️ "SQL is not Pseudocode"

If a keyword appears in Topic 8 (Programming) but not in Topic 9 (Databases), it doesn't belong in an SQL script. OUTPUT, DECLARE, IF, DIV, MOD → pseudocode only. SELECT, FROM, WHERE, ORDER BY → SQL only.

🗝️ "S-F-W-O" — clause order for later labs

SELECT → FROM → WHERE → ORDER BY. That's the clause order you'll use in the Querying Lab, with AND / OR inside WHERE and ASCENDING / DESCENDING after ORDER BY.

Your logged mistakes

No mistakes logged yet. Come back after Practice and Exam.

Recent Vault entries

Nothing in the Vault yet. Save key facts from Book Notes or from question feedback.

🏆 Mastery

Every skill you attempt (in Table Architect, Practice, or Exam) is scored. Get 3+ attempts with 70%+ accuracy on a skill and it goes green — mastered.

Tap a skill badge to override its status (e.g. mark it Mastered by hand once you're confident, or set it back to In Progress to force more practice).

No attempts yet.

📝 Revision checklist

Tick each item as you cover it. Save your progress by leaving this browser open.

Achievements

Complete Practice and Exam to unlock achievements.

➡️ Next up

Next, the Querying Lab uses SELECT, FROM, WHERE, AND, OR and ORDER BY to pull exactly the data you need out of a table.

Mistake log

Mistakes

Your recent mistakes

Progress

Stats & progress

Practice

0Attempts
–Accuracy

Exam

0Attempts
–Average key points
Bookmarks

Bookmarked questions

No bookmarks yet. Bookmark a question in the Exam tab to save it here.

My notes

My notes

Add note

Title
Note

Your notes

📝 Notes on this page

Spot a bug, a confusing explanation, or something to improve? Jot it down here. These notes are saved on this device only — they are not sent to anyone.

Category
Details
Knowledge Vault 2.0

Knowledge Vault

Add entry

Category
Confidence
Title
Info

Entries

Saved ✓