One morning Maya Sari emails Bookshop: please erase my personal data. Her name sits in MySQL, in the warehouse, in the lake's files, in a Kafka topic and in the backups. Which ones must be erased, and does the sales report change? Questions like these belong to data governance: the set of rules and habits around data, from who owns it, what it means and where it came from, to who may see it and how long it is kept. Data lineage is one part of it: the family tree of a number, from the source table to the report. It's like packaged food. Every pack has a label: where the ingredients came from, the factory, the expiry date, who is responsible. If one ingredient turns out to be contaminated, the factory traces it back to its supplier, then pulls every product on the shelves that used it. Some storerooms are open only to certain staff. The label is the catalogue, tracing back and pulling from the shelves is lineage, the storeroom key is access control, and the expiry date is retention.
Owners and the data catalogue
Every dataset needs an owner: the person or team who answers "is this number right?", approves who may read it, and is contacted when it breaks. At small Bookshop, the owner is one data team. In a big company, the orders table belongs to the checkout team and the marketing tables to the marketing team.
A data catalogue lists every dataset with its details: description, owner, columns and their meaning, classification, last update, and lineage. Its purpose is to let people find, understand and trust the datasets there are without asking another team. In a dbt project those details go in the same YAML as the tests. This passes dbt parse on dbt 1.12.5 with no warnings:
models:
- name: dim_customer
description: "One row per Bookshop customer."
config:
meta:
owner: data-team
retention: "anonymise when the customer asks to be erased"
columns:
- name: name
description: "The customer's name."
config:
meta:
pii: true
tags: ["pii"]
- name: city
config:
meta:
pii: quasi
dbt docs generate puts all of this on the dbt documentation site. For many systems at once (warehouse, Kafka, dashboards, dbt), teams use a separate catalogue such as DataHub (1.6, Apache 2.0) or OpenMetadata (2.0, Apache 2.0), which pull metadata from all of them.
Lineage: where does this number come from?
Data lineage is tracking where data comes from: its source, the transformations it went through, and where the result goes. In a dbt project, model-level lineage comes free: every ref() is an arrow. Two directions are used most:
- Upstream (debugging): "Why is London's best seller for the week of 28 September The Rainbow Troops 3?" Trace
weekly_best_sellerstofact_salestostg_order_itemstoorder_items, and find duplicate item 9, dropped in staging. - Downstream (impact analysis): "The app team wants to rename
customers.city. What breaks?" The output ofdbt ls --select source:bookshop.customers+ --resource-type model:
bookshop.marts.dim_customer
bookshop.marts.fact_sales
bookshop.marts.weekly_best_sellers
bookshop.staging.stg_customers
Four models. Column-level lineage is finer: which column is made from which. For the city column of the owner's report, read straight from the model files:
| Column | Made from | File |
|---|---|---|
weekly_best_sellers.city |
p.city |
models/marts/weekly_best_sellers.sql |
dim_customer.city |
coalesce(city, 'Unknown') |
models/marts/dim_customer.sql |
stg_customers.city |
city |
models/staging/stg_customers.sql |
customers.city |
the source, MySQL | _sources.yml |
A plain-looking report column turns out to come from customers' addresses. dbt Core draws lineage per model; lineage per column needs a tool that reads the SQL, such as DataHub or OpenMetadata. For pipelines outside dbt (Airflow, Spark), OpenLineage (1.53) is the open standard for sending lineage events from each run to a catalogue.
Personal data at Bookshop
Personal data is data about a person who can be identified, alone or combined with other data. It is often called PII (personally identifiable information). The customers table in this example holds only a name and a city; a Laravel app usually also stores an email in the users table, and that is personal data too.
| Column | Classification | Shop owner | Analyst |
|---|---|---|---|
name |
personal data (full name) | sees it | masked |
city |
personal once combined with a name | sees it | sees it |
customer_key |
a key made by the warehouse | sees it | sees it |
title, qty |
not personal data | sees it | sees it |
An analyst counting buyers per city does not need their names. So the mart gets a view that masks the name, and the analyst is given access to that view only:
CREATE VIEW dim_customer_analyst AS
SELECT customer_key,
CASE WHEN name IS NULL THEN NULL ELSE substr(name, 1, 1) || '***' END AS name,
city
FROM dim_customer;
The result in SQLite (the Lab): 1 | B*** | London, 2 | S*** | Bristol, 6 | M*** | Unknown. Another way: replace the name with a hash (SHA-256 of the email, say) so one person's rows can still be joined without showing who it is.
Access by role
Access control decides who may read what, per role, not per person. In PostgreSQL:
GRANT SELECT ON dim_customer_analyst TO analyst;
REVOKE SELECT ON dim_customer FROM analyst;
Cloud warehouses have per-column ways: BigQuery with policy tags on columns, Snowflake with masking policies. The principle is least privilege: each role gets only the access it needs. Add an audit log, a record of who read which table and when, so access can be checked afterwards.
The right to erasure and retention
Maya asks for her personal data to be erased. In the app's MySQL:
UPDATE customers SET name = NULL WHERE id = 6;
Then dbt build rebuilds dim_customer, and Maya's name becomes NULL there too. Her sales stay: 2 rows and 2 books in fact_sales, and weekly_best_sellers keeps its 9 rows with 15 books in total. The row "Unknown, week of 5 October: This Earth of Mankind 1", Maya's order, is still there. What is erased is the identity, not the transaction: the shop still needs its sales figures for reports and tax.
Retention is how long data is kept. Two directions have to be reconciled:
- Bookkeeping must be kept: UK tax rules require a company to keep its books, records and the documents behind them for 6 years from the end of the financial year they relate to.
- Personal data must be deleted or destroyed when it is no longer needed, its retention period ends, or the person asks (UK GDPR Articles 5(1)(e) and 17).
Erasure must also chase the copies: raw files in the lake (the bronze layer), old events in the Kafka topic (kept 7 days), snapshots and backups. The same lineage shows where the data flowed.
💡 UK GDPR and GDPR, briefly (not legal advice)
The UK GDPR and the Data Protection Act 2018 govern personal data in the UK, where Bookshop sells. The UK GDPR is the EU's GDPR (below) kept in UK law, with the same rights, such as erasure. Its Article 9 sets apart special category data (among others health, genetic and biometric data, religious beliefs, ethnic origin), which has stricter rules; a full name is ordinary personal data. Article 17 gives the data subject, the person whose data is processed, the right to have it erased.
GDPR (the General Data Protection Regulation, Regulation (EU) 2016/679) has applied since 25 May 2018 in the European Union, and also to businesses outside the EU that offer goods or services to people there (Article 3(2)). Its content is similar: the right to erasure (Article 17), keeping data only as long as needed (Article 5(1)(e)), and fines up to 20 million euros or 4% of global annual turnover, whichever is higher (Article 83(5)). Bookshop sells only in the UK, so the UK GDPR is the version that applies to it. This is a summary for engineers, not legal advice: take compliance decisions to a lawyer.
⚠️ Deleting, masking and cataloguing: where it goes wrong
- Erasing in MySQL only. Maya's name lives on in the warehouse until the next build, in the lake's bronze files, in the Kafka topic and in backups. Use lineage to find every copy.
- Masking in the dashboard only. An analyst who can query the base table still sees the names. Mask in the warehouse, and grant access by role.
- Deleting the transactions to "delete the customer". Reports and bookkeeping get holes. Anonymise the identity, keep the facts.
- A catalogue without owners. Descriptions nobody maintains go stale fast, and people go back to asking in chat. Every dataset needs a named owner.
TL;DR: Data governance covers the owner, meaning, origin, access and lifetime of data. A data catalogue (dbt docs, DataHub, OpenMetadata) lets people find, understand and trust datasets without asking another team. Data lineage tracks where data comes from: its source, its transformations, where it goes; in dbt every ref() is an arrow, upstream for debugging, downstream for impact (customers flows into 4 models), and column lineage shows weekly_best_sellers.city comes from customers.city. Customer names are personal data: mask them in the mart (B***), grant access per role with GRANT, log the access. When Maya asks for erasure, her name becomes NULL and her transactions stay (the report keeps 9 rows), in every copy. Bookkeeping is kept 6 years (UK tax rules), personal data is deleted when no longer needed (UK GDPR). The GDPR has applied since 25 May 2018; in the UK, the UK GDPR and the Data Protection Act 2018 apply.
⚡ Owners and the catalogue
Meaning: Every dataset needs an owner who answers "is this number right?". A data catalogue records each dataset's description, owner, columns and lineage, so people can find, understand and trust the datasets there are without asking another team.
⚡ Lineage: upstream and downstream
Meaning: Lineage tracks where data comes from: its source, its transformations, and where the result goes. In dbt every ref() is an arrow. Upstream for debugging, downstream for impact analysis: customers flows into 4 models.
⚡ Mask the name
Write:
CREATE VIEW dim_customer_analyst AS
SELECT customer_key,
CASE WHEN name IS NULL THEN NULL ELSE substr(name, 1, 1) || '***' END AS name,
city
FROM dim_customer;
Meaning: An analyst counting buyers per city doesn't need their names. They get access to this view only, through GRANT per role.
⚡ The right to erasure
Guess first: Maya asks for her personal data to be erased. Do her sales disappear from the report too?
No. Her name becomes NULL, but her transactions stay: weekly_best_sellers still has 9 rows. What is erased is the identity, not the transactions.
Meaning: Erase it in every copy: MySQL, the warehouse, the lake's bronze files, the Kafka topic and the backups. Lineage shows where they all are.