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

Free lesson

6.7 (2 of 3): Keeping data good: quality checks

The whole lesson, free. Read it and have a go at the activities. To work the tasks and labs in the real lesson, press Start lab, with no account needed.

45 minutes

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

The trip form that went wrong

Somebody types a school trip form into a computer. Look at the list.

Sam is 160 years old. Aisha has two rows. Leo lives at "LS1 1AB" on one list and "LS1 1BA" on another. The bus company sends the tickets to the wrong place.

Six checks can stop this. This lesson covers all six.

Key words

WordWhat it meansExample
ValidationA check that data is sensible and in the right shape.An age of 160 is refused.
VerificationA check that data was copied or typed in correctly.Type your email twice.
ReliabilityData you can depend on, from a trusted source.A school office list
ConsistencyThe same fact matching everywhere it is kept.One address, two lists, no difference.
IntegrityData staying complete, correct and joined up.A ticket always points to a real student.
RedundancyThe same data kept more than once when it is not needed.Aisha twice in one list
RecordOne row of data about one thing.Sam, 16, LS1 1AB
Range checkA rule that a value must be between two limits.Age from 11 to 19

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

Validation: is it sensible?

Validation checks that data is sensible and in the right shape. The computer does it by itself, when the data goes in.

Age 160? Refused. A postcode with no space? Refused. An empty name? Refused. Validation is a gate at the door.

Quick check: validation

Have a go

Quick check: validation

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

Try it: validation is not proof

Code: python
age = 17          # the student is really 16

if 11 <= age <= 19:
    print("Valid: the age is sensible.")
else:
    print("Refused.")

# Validation says yes, but the age is wrong.
# Change 17 to 160 and press Run again.

Make a free account to save your work and track your progress.

Verification: was it typed right?

Verification checks that the data was copied or typed in correctly. The age 17 passes validation, but only a second look shows it should be 16.

Common ways: type the data twice (double entry), or ask a person to read it back and check.

Two checks, one after the other

A flowchart from "Data typed in" to "Validation: sensible?", where no leads to "Refuse and ask again" and yes leads to "Verification: typed right?", where no also leads to "Refuse and ask again" and yes leads to "Save the record".A flowchart from "Data typed in" to "Validation: sensible?", where no leads to "Refuse and ask again" and yes leads to "Verification: typed right?", where no also leads to "Refuse and ask again" and yes leads to "Save the record".

Four more ideas

Reliability: you can depend on the data. It comes from a trusted source and does not change by itself.

Consistency: the same fact is the same in every place. The address is not different on two lists.

Integrity: the data is complete and not damaged. Every ticket points to a real student.

Redundancy: needless copies. Aisha is on the list twice.

Quick check: the four ideas

Have a go

Quick check: the four ideas

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

Some copies are good

Note

Many people think every copy is a problem. A backup is a planned copy that protects you when the first one is lost. Copies are a problem only when nobody planned them, because then they can disagree.

When to use each check

CheckIt asksUse it when
ValidationIs this sensible?Data goes in
VerificationWas this copied right?Data is typed or moved
ReliabilityCan we trust the source?You pick where data comes from
ConsistencyIs it the same everywhere?Data is kept in many places
IntegrityIs it whole and joined up?Data is stored for a long time
RedundancyIs there a needless copy?You tidy or design a store

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

Match the problem to the check

Have a go

Loading…

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

Watch: keeping data good

Press Play on the short film below. It starts with the trip form that went wrong. Then it shows the six checks and ends with a myth.

Film: keeping data good

Keeping data good: quality checks

Every scene, as text

  1. The trip form that went wrong. Aisha has two rows. Leo: "LS1 1AB" on one list, "LS1 1BA" on another. The bus company sends the tickets to the wrong place.
  2. Validation: is it sensible? A postcode with no space? Refused (refused: the wrong shape). An empty name? Refused (refused: empty). Range check: age from 11 to 19 (range check: a value between two limits).
  3. Verification: was it typed right? Validation says yes, but the age is wrong (so: validation is not proof). Type the data twice, or a person reads it back (verification: a second look). Validation: is it sensible? Verification: is it right?
  4. Four more ideas. Reliability: you can depend on the data (from: a trusted source). Consistency: the same fact is the same in every place (broken: Leo's two postcodes). Integrity: the data is complete and not damaged (so: every ticket points to a real student). Redundancy: needless copies (example: Aisha on the list twice).
  5. Myth (false): every copy is a problem. That is not true: some copies are good. A backup protects you when the first one is lost (copy: planned). Copies nobody planned can disagree (copy: not planned, like Aisha's two rows).

Your turn: build the checks

Build four small checks for the school trip form. The first checks an age. The second checks the shape of a postcode. The third checks double entry. The fourth removes needless copies from a list. Read the comments in the starter. Press Run Tests to check.

Code: python
def valid_age(age):
    # A student's age must be a whole number from 11 to 19.
    # Give back True or False.
    return None


def valid_postcode(text):
    # A very simple UK postcode check. Give back True only when ALL of these are true:
    # - the text, with spaces taken off both ends, is 6 to 8 characters long
    # - it has exactly one space inside it
    # - the first character is a letter
    # - the last three characters are: a digit, a letter, a letter
    # Example: "LS1 1AB" is True. "LS11AB" is False.
    return None


def entries_match(first, second):
    # Double entry: the person types the email twice.
    # Give back True only if both are exactly the same.
    return None


def remove_duplicates(names):
    # Give back a new list with every name once, in the order it first appeared.
    return None

Make a free account to save your work, or press Start lab to work through the whole lesson.

Key words crossword

Have a go

Loading…

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

Final check

Have a go

Final check

5 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

Remember

Tip

Validation asks: is it sensible? Verification asks: is it right? Then keep the data reliable, consistent and whole, and remove needless copies.

Teach this lesson with your class

On a college account your students work the tasks and the labs as well, and every mark is kept for you.