Cambridge IGCSE · Topic 9 (1-3)
IGCSE Computer Science 0478 / Topic 9 / IGCSE

Data in rows and columns.

A vet surgery, a school library and a games shop all keep the same kind of data again and again: one set of details for each pet, book or game. A database table stores it neatly in rows and columns, so it can be searched and sorted in seconds.

The key idea

A database is a structured collection of data that allows people to extract information. In a single-table database all the data is in one table. Each field (column) holds one item of data, such as Name or Weight. Each record (row) holds all the data about one person or thing. Every field is given a data type: text/alphanumeric, character, Boolean, integer, real or date/time. Validation rules check that data entered into a field is sensible.

table PETS PetIDNameSpeciesWeightVaccinated P01BellaDog12.5TRUE P02TomCat4.2FALSE P03NibblesRabbit1.8TRUE P04MaxDog30.1TRUE a field (column): one item of data a record (row): all the data about one pet
Fig. 1: the PETS table has 5 fields and 4 records
Section 01

Tables, fields and records.

In the lab, click a column heading to highlight a field and click a row to highlight a record. Count how many of each the table has.

Examiner trap

Do not mix the two words up. A field is a column (one kind of data); a record is a row (one item). Swapping them loses the mark.

Section 02

Choosing data types.

Pick the data type that matches what the field will hold and what you will do with it. Ask: is it a whole number, a decimal, yes/no, a date, one character, or a mix of letters and digits?

Data typeHoldsExample field and value
Text / alphanumericany letters, digits and symbolsName: Bella; Postcode: LS1 4AB
Characterexactly one letter, digit or symbolSize: M
Booleanone of two values, TRUE or FALSEVaccinated: TRUE
Integera whole numberNumberOfVisits: 7
Reala number with a fractional (decimal) partWeight: 12.5
Date/timea date or a timeDateOfBirth: 14/03/2022
Worked example Phone numbers
Suggest a data type for a field that stores a telephone number such as 01632 960 123, and justify it.
  1. The number starts with a 0, and an integer would drop the leading zero.
  2. It may contain spaces or a + sign, and no arithmetic is ever done on it.
Answer: Text / alphanumeric
Your turn
Suggest data types for: (a) a pet's weight in kg, (b) whether a pet is microchipped, (c) a pet's ID such as P01.
Examiner trap

"Number" and "string" are not accepted as answers. Give the exact type: integer or real, and text/alphanumeric.

Stage 1 · Learn

Check what the sim just showed you

Four quick checks. Each correct answer earns XP and records this skill on your profile.

Quick check+10 XP

What is a record in a database table?

Quick check+10 XP

In the lab's table, each column such as Title or Price is called what?

Quick check+10 XP

Which data type is most suitable for the number of goals a player has scored?

Quick check+10 XP

Which data type is most suitable for whether a library book is on loan?

Section 03

Defining a table and validation.

To define a single-table database from given data, list each field with a sensible name, a data type and, where useful, a validation check. Validation does not prove data is correct, only that it is reasonable.

Field nameData typeValidation
PetIDTextFormat check: letter P then two digits; presence check
NameTextPresence check; length check (1 to 20 characters)
SpeciesTextLookup check: Dog, Cat, Rabbit or Bird
WeightRealRange check: greater than 0 and no more than 100
VaccinatedBooleanType check: TRUE or FALSE only
DateOfBirthDate/timeType check: a real date, not in the future
Examiner trap

A range check on Weight would still accept 21.5 when the dog really weighs 12.5. Validation checks that data is sensible, not that it is accurate.

Stage 2 · Exam

Exam-style questions

Unlocks once the four checks above are done. Worth more XP, written to IGCSE Paper 1 standard.

Finish the four checks above to unlock the exam questions
Exam style+20 XP

A table has field names in the top row and 12 rows of data about 12 students, with 6 columns. How many records and fields does it have?

Exam style+20 XP

Which data type should be used for a product price such as 4.99?

Exam style+20 XP

Why should a mobile phone number be stored as text rather than integer?

Exam style+20 XP

Which validation check is best for a field holding a student's age, from 11 to 18?

Skill unlocked

Fields, records and data types, mastered.

This skill is now recorded on your profile. Keep the chain going.

-Rank -Level -Score -Topics
Go deeper · practice
Six original Cambridge-style questions
Tables, fields and records, choosing data types and suggesting validation for a single-table database.