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.5: Splitting data apart and putting it back

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

One box, two facts

A form has one box for "Name": Amy Reed. The club wants to sort by last name. It cannot, because the first name and the last name are stuck together.

Break the box into two. Later, join the parts back in a new shape.

Key words

WordWhat it means
Decomposesplit data into its smaller parts
Constituent partone of the smaller pieces a value is made of
Recomposejoin the parts back together into a whole
Delimiterthe mark that separates parts, such as a space or a slash
Atomic fielda field that holds one fact only
Fit for purposegood enough for the job the data is needed for

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

By the end of this lesson

Note

I can split a value into its parts and join the parts back into a form that suits the job.

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.

Worked example: splitting and joining

WholeParts (decomposed)New whole (recomposed)Why
Mary Jane ReedMary and ReedReed, MarySort by last name
07/09/20267, 9 and 20262026-09-07Sorts into date order
12 High St, LeedsNumber, street, townLeedsCount members by town
AMY-03-Y9Initials, form, yearY9Count pupils by year

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

Why split at all?

A field that holds two facts cannot be sorted, filtered or counted by either one. A field that holds one fact can.

Splitting is the first step. Joining is the last step: the parts are put back in the shape the next job needs.

Try it: split and join in Python

Code: python
full = "Mary Jane Reed"
words = full.split()
first = words[0]
last = words[len(words) - 1]
print(last + ", " + first)

text = "07/09/2026"
parts = text.split("/")
print(parts[2] + "-" + parts[1] + "-" + parts[0])

# Change the date to 25/12/2025 and run it again.

Try it: the same jobs in SQL

Code: sql
SELECT full_name,
  substr(date_text, 7, 4) || '-' || substr(date_text, 4, 2) || '-' || substr(date_text, 1, 2) AS iso_date
FROM sign_ups;

-- substr(text, start, length) cuts out a part.
-- The two bars join parts together.

Check

Have a go

Check

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

4 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.