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

Preview

AESP task 2: Fix the data, explain why, test again

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

65 minutes

Found a fault. Now what?

You have found six bad rows. The easy answer is to delete them all. But one of those rows is a real payment with a typing slip.

Every fix is a decision. A good decision has a reason and a test that proves it worked.

Key words

WordWhat it means
Remedial actiona step taken to put a fault right
Cleanseto correct or remove bad data so what is left can be trusted
Regressiona new fault caused by a fix, or an old fault that comes back
Retestto run the tests again after a fix
Conventionan agreed way of writing something, such as a date as YYYY-MM-DD
SQLa language for asking questions of data kept in tables
Querya question you ask of data, written in SQL

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

By the end of this lesson

Note

I can choose a fix for each fault, justify it, make it safely, follow the data conventions and test again.

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.

This is practice

Important

The real task comes from the exam board. This lesson uses an invented organisation and its own made-up data. Your teacher tells you how the real tasks are set and what you may bring.

Worked example: four ways to fix

ActionWhen to use itExample from the deposits
RemoveThe row is a repeat or has no real meaningRow 4 repeats row 2
CorrectYou know the true valueBranch SOUTH becomes South
Fill inYou can work out the missing value from a ruleNo rule here, so do not guess
Flag and askOnly the owner knows the answerRow 5 has no amount: ask the branch

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

Say why for every fix

Write the reason beside the action. "Removed row 4 because it repeats row 2 in every column and would add £40 to the total twice."

Never guess a missing amount to make a total look complete. A guess that looks real is worse than a gap that is marked.

Run it: fix on a copy

Code: sql
CREATE TABLE deposit_raw AS SELECT * FROM deposit;
DELETE FROM deposit WHERE deposit_id = 4;
UPDATE deposit SET branch = 'South' WHERE branch = 'SOUTH';
UPDATE deposit SET branch = 'North' WHERE branch = 'north';
SELECT branch, COUNT(*) AS rows_in FROM deposit GROUP BY branch;

Always keep the original

Tip

The first line copies the raw table. If a fix is wrong you can go back. Nobody can prove a fix was right if the original is gone.

The lesson goes on

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