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

Preview

Unit 9 C2: Keeping data accurate and clean

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

A phone number with seven digits

Greenfield Youth Club (made up) is moving its members from an old list to a new system. One phone number has only seven digits. One town is spelt Rivrside. One join date is the 40th of the 13th month.

If those go into the new system, the mistakes move with them. The new system must stop them at the door.

By the end of this lesson

Note

I can set rules that keep data valid and check moved data against a master list.

Key words

WordWhat it meansExample
Input maska pattern that each typed character must match07 then 9 digits
Default valuethe value a field gets if nobody types one
Validation rulea rule that refuses data that is not allowed
Master datathe one agreed list that other data is checked against
Data migrationmoving data from one system to another
Quality controlchecking data after it is entered to find errors

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

Starter: what you already know

Have a go

Starter: what you already know

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.

Four controls stop bad data at entry

The best fix is to stop bad data going in. Four controls do this.

An input mask forces a pattern, such as 11 digits starting 07. A default value fills a field when nobody types. A validation rule refuses values that break a rule, such as a range. A list allows only values from a short list, such as Active, Paused or Left.

The four controls

ControlWhat it doesExample
Input maskForces a patternPhone: 07 then nine digits
Default valueFills in when emptyStatus starts as Active
Validation ruleRefuses wrong valuesAge between 5 and 100
ListAllows only listed valuesStatus: Active, Paused or Left

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

Try it: check the old list

Code: sql
-- Mask check: phones that are not 07 plus nine digits.
SELECT member_ref, phone FROM old_members
WHERE phone NOT GLOB '07[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]';

-- Master list check: towns that are not on the master list.
SELECT member_ref, town FROM old_members
WHERE LOWER(TRIM(town)) NOT IN (SELECT LOWER(town) FROM master_towns);

-- Date check: dates that are not real dates.
SELECT member_ref, joined FROM old_members WHERE DATE(joined) IS NULL;

Check

Have a go

Check

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 lesson goes on

9 more parts of this lesson are in the full lesson, which colleges teach from the Library. A college account gives your students all of it.