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

Preview

DA 1.1: Select, prepare, extract, transform

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

50 minutes

Raw data is not ready data

A bakery has a sales table. One row says "test row". One row has no quantity. Nobody wants those in the weekly report.

Before analysis, an analyst follows a short routine: choose the data, check it, take it out, and change it. All the time, the rules about data apply.

Key words

WordWhat it meansExample
ComplianceFollowing the law and the security rules that apply to the data.Obeying data protection law
SelectTo pick out which data you need.Only the sales table
PrepareTo check the quality of the data and fix what you can.Find rows with no quantity
ExtractTo take the data you need out of its source.Copy the rows into a new file
TransformTo do a calculation or change on the data.Quantity times price gives the total
QueryA question you ask a database in a special language.Show all sales of buns
SQLThe language used to write a query for a database.select item from sales
DatabaseA store of organised data that a program can search.The bakery sales table

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

By the end of this lesson

Note

I can put select, prepare, extract and transform in order and do each one with a query.

Starter: what you already know

Have a go

Starter: what you already know

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.

What each step does

Compliance is not one step. It runs beside all of them. Ask: may I use this data, and am I keeping it safe?

  1. Select the data that answers the question.
  2. Prepare it: check the quality.
  3. Extract it: take out what you need.
  4. Transform it: calculate or change it.

Try it: select and prepare

Code: sql
-- Prepare: find the rows that have a problem.
select id, item, qty, note
from sales
where qty is null or note = 'test row';

-- Try it: add or id = 6 to see one more row.

Try it: extract and transform

Code: sql
-- Extract the good rows, then transform: total = qty times price.
select day, item, qty * price as total
from sales
where qty is not null and note <> 'test row'
order by day;

-- Try it: change the order to total desc.

Worked example: one row through the routine

StepWhat we doRow 3 now
SelectPick the sales tablebun, 6, 2
PrepareCheck for no quantity and test rowsGood row
ExtractKeep the good rowsRow kept
Transform6 times 2Total is 12

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

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.