9.1

Topic 9

Databases

  • IGCSE Computer science 0478
  • 3 min read
  • Syllabus 2026, 2027 and 2028

Objectives

  1. 1

    Define a single-table database from given data storage requirements

  2. 2

    Suggest suitable basic data types

  3. 3

    Understand the purpose of a primary key and identify a suitable primary key for a given database table

  4. 4

    Read, understand and complete structured query language (SQL) scripts to query data stored in a single database table

Cambridge IGCSE Computer Science 0478 syllabus 2026-2028, 9.1 Databases (copied for internal use as permitted by Cambridge)

Detailed · Deep study

1Single-table databases

field

A single item of data about something, shown as a column in a table, e.g. Author.

record

All the data about one item, shown as a row in a table, e.g. all the details of one book.

Fig. 1Fields and records.

To define a table from given data storage requirements, decide the table name, the fields needed, a suitable data type for each, the primary key, and any validation on the fields (e.g. a range check on Price, a presence check on Title, a format check on BookID).

See Topic 7 · Algorithm design and problem-solvingValidation checks are covered in 7.1.

2Data types

Data typeStoresExample field
text/alphanumericletters, digits and symbolsTitle, BookID, phone number
charactera single characterGrade (A–E)
Booleanone of two values: TRUE/FALSE (Yes/No)InStock
integera whole numberPages
reala number with a decimal partPrice
date/timea date and/or timeDateBorrowed

3Primary keys

primary key

A field that contains a unique value for every record, so that each record can be identified.

Author is not a suitable primary key, because two books can have the same author; BookID is suitable because each book is given a different ID.

4Structured query language (SQL)

SQLMeaning
SELECTthe fields to show (* for all fields)
FROMthe table to search
WHEREthe condition records must meet
ORDER BY … ASC / DESCsort the results in ascending or descending order
SUM( )adds up the values of a numeric field
COUNT( )counts the number of records
AND / ORcombine conditions: both must be true / at least one must be true
The table Books.
BookIDTitleAuthorGenrePagesPriceInStock
B001The Silent SeaAde OkaforThriller3208.99TRUE
B002Stars AboveMia ChenSci-fi41012.50FALSE
B003Lost ValleyAde OkaforAdventure2757.25TRUE
B004Code BreakersRaj PatelThriller3609.99TRUE
B005Red PlanetMia ChenSci-fi2906.50TRUE
B006River SongLena RuizAdventure1985.99FALSE
SELECT Title, Author
FROM Books
WHERE Genre = 'Thriller';
Output: The Silent Sea, Ade Okafor; Code Breakers, Raj Patel.
SELECT Title, Price
FROM Books
WHERE Price < 8.00
ORDER BY Price ASC;
Output, in ascending order of price: River Song 5.99; Red Planet 6.50; Lost Valley 7.25.
SELECT BookID, Title
FROM Books
WHERE Genre = 'Adventure' AND InStock = TRUE;
Output: B003, Lost Valley (River Song is an adventure book but is not in stock).
SELECT Title
FROM Books
WHERE Genre = 'Sci-fi' OR Pages > 350
ORDER BY Title DESC;
Output, in descending (Z to A) order of title: Stars Above; Red Planet; Code Breakers.
SELECT COUNT(*)
FROM Books
WHERE InStock = TRUE;
Output: 4 – the number of records that match.
SELECT SUM(Pages)
FROM Books
WHERE Author = 'Mia Chen';
Output: 700 – the total of the Pages field for matching records (410 + 290).

5Exam focus

Key words: database; table; field; record; data type; primary key; SQL; SELECT; FROM; WHERE; ORDER BY; ASC; DESC; SUM; COUNT; AND; OR.

Quick self-check

Answer in your head first, then reveal.

  1. 7 (1).

  2. Titles may not be unique / two books could have the same title (1).

  3. SELECT Title, Pages (1) FROM Books (1) WHERE Author = 'Ade Okafor' (1) ORDER BY Pages ASC (1).

  4. 2 (1).

  5. Real (1).

Finished this subtopic? Track it on your subject page.