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: Records that cannot be used as they are

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

60 minutes

Counted twice, counted never

A club list has 6 rows. Two members appear twice. One row is completely empty. One member left the club in 2019.

The club says it has 6 members. It really has 3 or 4. Some rows should never have been counted.

Key words

WordWhat it means
Recordone row of a table: all the facts about one thing
Blank recorda row with nothing in it
Duplicatea record that appears more than once
Out of datea record that is too old to be useful for the job
Out-of-date fieldone value in a record that has not been checked for too long
Unfit for processingnot usable in a calculation or a report as it stands
Databasean organised store of tables that you can ask questions
SQLthe language used to ask a database for data

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

By the end of this lesson

Note

I can spot records that are unfit for processing and remove them, and say why each one is a risk.

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.

Records and fields that cause trouble

ProblemExampleWhat goes wrongUsual fix
Blank recordA row of empty boxesCounted as a memberRemove it
Duplicate recordAmy 8 appears twiceCounted twiceKeep the first, remove the rest
Out-of-date recordCy joined in 2019 and leftCounted as currentRemove or archive it
Out-of-date fieldA phone number last checked in 2020Calls reach nobodyMark for a re-check

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

Try it: see the repeats with SQL

Code: sql
-- Every row, including repeats.
SELECT COUNT(*) AS rows_in_table FROM members;

-- DISTINCT keeps one copy of each different row.
SELECT DISTINCT name, year, joined FROM members;

-- Who is old? Joined before 2022.
SELECT name, joined FROM members WHERE joined < 2022;

Be careful before you delete

Removing a record is a decision. A row that looks like a repeat may be two real people with the same name and year.

Compare all the fields, not just the name. Keep the original file, clean a copy, and write down what you removed and why.

Extra: Finding repeats with HAVING

Group the rows by all their fields and keep the groups with more than one row: SELECT name, year, joined, COUNT(*) FROM members GROUP BY name, year, joined HAVING COUNT(*) > 1;

This lists each repeated record once, with how many times it appears.

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.