Why does a newsletter need a birth date?
Data minimisation means collecting only the personal data you need for a clear purpose. Data you never collect cannot leak, be misused or need deleting later.
A sign-up form for a newsletter needs one thing, an email address. Many forms also ask for a phone number, a birth date and a postcode, and every extra field is a risk.
By the end of this lesson
Note
I can reduce the personal data a system collects and shares.
Key words
| Word | What it means | Example |
|---|---|---|
| Data minimisation | collecting only what the purpose needs | |
| Purpose | the reason you collect the data | |
| View | a saved query that shows chosen columns | |
| Generalise | replace a precise value with a broader one | 1994-03-18 becomes 1994 |
| Need to know | each person sees only what their job needs |
The cells students fill in are left blank in this preview.
Start with the purpose, then list needs
Write down why you collect the data. Then ask of each field: could we do this without it?
If the answer is yes, do not collect it. A field kept "in case it is useful" has no purpose yet, so it should not be there.
A purpose also limits use. Data collected to send a parcel is not free to be used for something else.
Worked example: what each purpose needs
| Purpose | Needed | Not needed |
|---|---|---|
| Send a newsletter | Email address | Phone, birth date, postcode |
| Deliver a parcel | Name, address, a contact for the courier | Birth date, health details |
| Check a buyer is an adult | A yes or no answer | The full birth date |
| Count visitors by area | The first part of the postcode | The full postcode, the name |
The cells students fill in are left blank in this preview.
A view shows only needed columns
Not everyone in a company needs every column. The team that sends the newsletter does not need phone numbers.
A view is a saved query. People who read the view see its columns and nothing else. The table underneath stays as it is.
Use the first two lines from last time if your terminal is new, then make a view with three columns.
Accept the server's certificate
printf '[client]\nssl-verify-server-cert=0\n' > ~/.my.cnfShown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Make a short name for the shop
alias sql='mariadb -h db -u student -pstudent shop -t -e'Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Make a view with three columns
sql "CREATE OR REPLACE VIEW student_mailing AS SELECT id, first_name, country FROM customers"Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Read the first three rows of the view
sql "SELECT * FROM student_mailing ORDER BY id LIMIT 3"Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Ask the view for a column it lacks
sql "SELECT email FROM student_mailing"Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
A view hides unselected columns
The first read prints customers 1, 2 and 3: Lucas in the United Kingdom, Ines in France and Elena in Ireland. Only id, first name and country exist in the view.
The second read fails with an error that says the column email is unknown. The view has no such column, so the team cannot see it.
A common mistake
Warning
Many people think a view locks the table. It does not. Anyone who can read the table can still read every column. A view protects only when people are given access to the view and not to the table.
Generalise a value to share less of it
Sometimes a team needs a rough value. A birth date can become a birth year, or an age band. A full postcode can become its first part.
The rough value still answers the question, such as "how many readers are under 30?", but it points at far fewer people.
Try it: broader versions of two values
-- Keep a broader version of two precise values.
SELECT id,
SUBSTR(birth_date, 1, 4) AS birth_year,
SUBSTR(postcode, 1, 3) AS area
FROM signups
ORDER BY id;
-- Change 1, 4 to 6, 2 to see the birth month instead of the year.
Remove the view when you finish
sql "DROP VIEW student_mailing"Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.