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

Free lesson

What counts as personal data

After this lesson: I can say whether a piece of data is personal data.

55 min lesson4 commandsMySQL and phpMyAdmin lab with a sample shop database to practise SQL

Is an email address personal data?

Personal data is any information about a person who can be identified from it. A name counts, and so do an email address, a phone number and a photo.

Knowing what counts decides which rules apply to a database, and so how carefully you must look after it.

A shop that keeps 40 customer rows holds personal data in more columns than you might expect.

By the end of this lesson

Note

I can say whether a piece of data is personal data.

Key words

WordWhat it meansExample
Personal datainformation about a person who can be identified
Identifiera detail that helps pick out one person
Direct identifiera detail that points at one person on its ownan email address
Indirect identifiera detail that points at a person only with othersa birth year
Sensitive datapersonal data that can cause serious harm if it leaks

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

Personal if a person can be found

The test has two parts. The data must be about a person, and that person must be identifiable from it.

Identifiable does not mean named. If you could work out who it is, using the data and other things you can reach, it is personal data.

Data protection law is written to protect the person the data is about.

Worked example: is it personal data?

ValuePersonal data?Why
[email protected]YesIt names a mailbox that one person reads
A delivery addressYesIt leads to one household
A phone numberYesIt reaches one person
The number of orders in MayNoIt is about the shop, not a person
The average price of a basketNoMany people are folded into one number

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

Look at a real customer table

The lab holds an invented online shop with 40 customers. Open the terminal and press Run on the first two lines. They let you ask short questions.

Then count how many different values each column holds. A column where every value is different can point at one customer.

Accept the server's certificate

Command
printf '[client]\nssl-verify-server-cert=0\n' > ~/.my.cnf

Shown 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

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

Count the different values

Command
sql "SELECT COUNT(*) AS customers, COUNT(DISTINCT email) AS emails, COUNT(DISTINCT city) AS cities FROM customers"

Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.

Direct identifiers point at one person alone

The run above prints 40 customers, 40 different emails and 12 different cities. An email is different for every customer, so it is a direct identifier.

A city is shared by many customers, so on its own it is an indirect identifier. Put a city with a birth year and a job, and the group can shrink to one person.

Try it: how groups shrink

Code: sql
-- How many visitors share each city and birth year?
SELECT city, birth_year, COUNT(*) AS people
FROM visitors
GROUP BY city, birth_year
ORDER BY people, city;
-- A row with people = 1 points at one person.
-- Add job to SELECT and to GROUP BY, then run it again.

A common mistake

Warning

Many people think data without a name is not personal. A city, a birth year and a job can still pick out one person. If the data can be traced to one person, even with effort, it is personal data. Take the name out and you must still check.

Count the phone numbers

Command
sql "SELECT COUNT(*) AS customers, COUNT(phone) AS phones FROM customers"

Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.

Some personal data is sensitive

The run above prints 40 customers and 30 phone numbers, because COUNT skips NULL. Ten customers gave no phone number.

Some data is more risky than a phone number. Health, religion, political views, sexual life and ethnic origin can lead to unfair treatment if they leak.

Many data protection laws ask for extra care with these, and often a clear and explicit reason to collect them.

About this lab and its source: MySQL and phpMyAdmin lab with a sample shop database to practise SQL

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.