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
| Word | What it means | Example |
|---|---|---|
| Validation | A check that data is sensible and in the right shape. | An age of 160 is refused. |
| Verification | A check that data was copied or typed in correctly. | Type your email twice. |
| Reliability | Data you can depend on, from a trusted source. | A school office list |
| Consistency | The same fact matching everywhere it is kept. | One address, two lists, no difference. |
| Integrity | Data staying complete, correct and joined up. | A ticket always points to a real student. |
| Redundancy | The same data kept more than once when it is not needed. | Aisha twice in one list |
| Record | One row of data about one thing. | Sam, 16, LS1 1AB |
| Range check | A 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 questionsTry it: validation is not proof
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
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 questionsSome 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
| Check | It asks | Use it when |
|---|---|---|
| Validation | Is this sensible? | Data goes in |
| Verification | Was this copied right? | Data is typed or moved |
| Reliability | Can we trust the source? | You pick where data comes from |
| Consistency | Is it the same everywhere? | Data is kept in many places |
| Integrity | Is it whole and joined up? | Data is stored for a long time |
| Redundancy | Is 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
- 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.
- 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).
- 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?
- 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).
- 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.
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 questionsRemember
Tip
Validation asks: is it sensible? Verification asks: is it right? Then keep the data reliable, consistent and whole, and remove needless copies.