Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Preview

AC 2.1: Choosing a data format for each field

This is the first page of the lesson. Read it and have a go at the activities. The rest is in the full lesson.

55 minutes

Is 007 a number?

A school shop keeps a list of its products. One box holds a price. Another holds a barcode that starts with zeros, like 007.

If the barcode is saved as a number, the zeros vanish and 007 becomes 7. The shop can no longer find the product. Choosing the right format for each box matters.

Key words

WordWhat it meansExample
Data formatthe kind of value a field holds, which decides what you can do with it
Fieldone box in a record, such as a price or a name
Integera whole number with no decimal point42
Decimala number with a decimal point2.50
Textletters, digits and symbols treated as wordsCheese roll
Booleana value that is only true or false
Date/timea day, a clock time, or both2026-09-07
Currencyan amount of money in one kind of money, such as pounds
Bloba binary large object: a file such as a picture, saved as raw bytes
Databasean organised store of records that you can ask questions

The cells students fill in are left blank in this preview.

By the end of this lesson

Note

I can name the seven data formats, say when each is used, and pick the right one for a field.

Starter

Have a go

Starter

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Your answers are marked here and are not kept. A college account keeps every student’s marks.

The seven formats

FormatHoldsExampleUse it for
IntegerWhole numbers30Stock count, age, quantity
DecimalNumbers with a point4.75Weight, temperature, average
TextWords and symbolsColaNames, codes, phone numbers
BooleanTrue or falsetrueIn stock, has paid, is a member
Date/timeA day and a time2026-09-07 12:30When a sale happened
CurrencyMoney2.50 poundsPrices, fees, totals
BlobA file as bytesa photoPictures, scans, audio

The cells students fill in are left blank in this preview.

How to choose

Ask what you will do with the value. If you will add it up, use a number. If you will only read it, use text.

A phone number or a barcode is text, even though it is made of digits. You never add two phone numbers, and a leading zero must stay.

Money needs care

A decimal can be a tiny bit wrong, because computers store it in binary. Adding 0.10 and 0.20 can give 0.30000000000000004.

So data work often saves money as whole pence: 2.50 pounds is stored as the integer 250. Divide by 100 only when you show it.

Try it: ask SQL for the format

Code: sql
SELECT typeof(42) AS whole,
       typeof(3.5) AS with_point,
       typeof('Cola') AS words,
       typeof(X'48') AS raw_bytes,
       typeof(price_pence) AS pence
FROM products LIMIT 1;

-- SQLite has no true date or Boolean format.
-- Dates are saved as text like 2026-09-07.
-- Booleans are saved as the integers 1 and 0.

Check: pick the format

Have a go

Check: pick the format

4 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Your answers are marked here and are not kept. A college account keeps every student’s marks.

The lesson goes on

5 more parts of this lesson are in the full curriculum, with the tasks, the final check and the labs. A college account gives your students all of it.