Scrivio Interview library
DesignIntermediate7 min read · updated 12 November 2026

GDPR requires erasing a customer's personal data on request, but data also lives in backups, a warehouse, Kafka topics and archives. Design how deletion works.

Start with a data inventory that maps every store personal data reaches, and define for each store how erasure happens. Keep personal data apart from business facts and encrypt it with a key per customer, so deleting that key makes every copy unreadable, including copies in backups and archives (crypto shredding). Kafka topics use compaction with tombstones or short retention, backups are re-erased from a deletion log on restore, and the warehouse runs deletion jobs driven by the same erasure events, each store reporting evidence back.

Why this question is asked

The right to erasure in GDPR sounds simple: when a customer asks, delete their data. In a real system the customer's name and email are in the main database, copied into a warehouse, replayed through Kafka topics, frozen inside nightly backups and stored in archives for years. Deleting a row in one database does not touch any of those. Interviewers ask this design question to see whether we treat erasure as a flow through the whole platform rather than a single DELETE statement. In this answer, we will start with the inventory of where data flows, look at crypto shredding as the core technique, then go store by store through Kafka, backups and the warehouse, and finish with how we prove that erasure happened.

1Start With a Map of Where Personal Data Goes

Personal data is any information that identifies a person directly or indirectly: name, email, phone, address, IP address, and often a customer id when it can be linked back. Before designing deletion, we need a data inventory, a register of every store that holds personal data, which fields it holds, who owns it, how data gets there, and how long it stays. Without it we will always miss the copy someone made for a report two years ago.

For each store the inventory records an erasure method. Some stores can delete directly, some can only expire data, and some, such as backups, cannot be changed at all. The design is about choosing the right method per store and connecting them all to one erasure request.

Erasure method per store
StoreHow erasure happensTime to effect
Operational databaseDelete or anonymise rows, delete the customer keyMinutes
Kafka topicsTombstone on compacted topics, or short retentionHours to days
WarehouseDeletion job consuming erasure eventsWithin a day
BackupsKey deleted; re-erase from deletion log on restoreBackup retention, e.g. 35 days
ArchivesKey deleted (crypto shredding)Immediate for reading
Every store needs an answer before the first request arrives.

2Separate Personal Data From Facts

Most of what a business keeps about an order is not personal: amounts, product ids, dates and status. Tax law may even require us to keep invoices for years. So we split the record: a customer profile holds the personal fields, and facts such as orders refer to the customer by a pseudonymous id, a random identifier that means nothing without the profile. Pseudonymisation is the GDPR term for this. After erasure, the facts remain for reporting and legal duties, but they no longer point to a person.

This split also keeps the deletion small. Instead of finding the customer's name in a hundred tables, we only have to deal with the few places where personal fields actually live.

3Crypto Shredding: Delete the Key, Not Every Copy

The hardest copies to erase are the ones we cannot edit: backups, immutable archives and old Kafka segments. Crypto shredding solves this. We encrypt the personal fields with a data key that belongs to one customer, kept in a key management service. Every store, backup and archive only ever holds ciphertext. When the customer asks for erasure, we delete their key. All copies, wherever they are, become unreadable at the same moment.

Java
// Writing a profile: personal fields are encrypted with the customer's own key
SecretKey key = keyService.keyFor(customerId); // created on first use
byte[] email = crypto.encrypt(key, "ana@example.com"); // ciphertext only
profiles.save(new Profile(customerId, email, encName));
// Erasure request
keyService.destroy(customerId); // the key is gone
crypto.decrypt(keyService.keyFor(customerId), email); // throws: no key for customer
// backups, archives and topic copies still hold bytes, but nobody can read them

Notice that the key service itself becomes the most important store: it must be highly available, backed up carefully, and its own backups must not keep deleted keys forever, or the deleted key could come back with a restore. Most teams keep key backups short and audited for exactly this reason. Crypto shredding is widely used for erasure, but whether it counts as deletion is a legal question, so we agree it with our privacy team.

4Kafka Topics: Tombstones or Short Retention

Kafka keeps messages until retention removes them, so a topic with customer events is another copy. For topics that hold the current state per customer, we use log compaction keyed by customer id. Compaction keeps only the latest record per key, and a record with a null value, called a tombstone, tells Kafka to remove the key entirely. After compaction runs and delete.retention.ms has passed, the tombstone itself disappears too. Compaction only touches segments that are no longer active, so we set max.compaction.lag.ms to put an upper bound on how long old values can survive.

For event topics that are not compacted, we keep retention short, for example seven days, and avoid putting personal fields in them at all, carrying only the pseudonymous id. If a topic must carry personal data for longer, we encrypt those fields with the customer key, so crypto shredding covers it.

5Backups and the Warehouse

We cannot edit a backup, and restoring every backup to delete one customer is not realistic. The usual approach, which we document in the privacy policy, is to limit backup retention, for example 35 days, keep a deletion log of every erased customer id, and when a backup is restored, replay that log before the restored data is used. Combined with crypto shredding, restored data is unreadable anyway, and the replay removes the leftover rows.

The warehouse gets the same erasure event as every other store. A deletion job consumes it and removes or anonymises the customer's rows in every table that the inventory lists. Warehouses often have time travel or snapshot features that keep old versions of tables for days, so the time travel window must be shorter than the deadline we promise. GDPR asks for erasure without undue delay and in any case within one month of the request, which gives the slowest store its deadline.

Step throughOne erasure request across the platform
Erasure serviceKey serviceKafkaWarehouse jobErasure ledger
destroy key for customer 81
tombstone key 81 on compacted topics
append id 81 to deletion log
erasure event for 81
delete rows in listed tables
done: 4 tables, 37 rows
done: key destroyed

7 messages in order. Play them, or step through them one at a time.

Each store reports back, so the ledger can prove the request is complete.

6Proving That Erasure Happened

Regulators and auditors will ask us to show that a request was handled. An erasure ledger records each request, its arrival time, the stores it had to reach, and when each store confirmed. A request is complete only when every store in the inventory has confirmed. A daily report lists requests close to their deadline, and a periodic test creates a fake customer, erases it, and checks that no store still returns its data.

7Follow-up questions

What about data we are legally required to keep, such as invoices?

Legal obligations, such as tax rules that require invoices for several years, are one of the grounds that limit the right to erasure. We keep the invoice facts but remove or restrict everything not needed for that obligation, and we record the legal basis and the date when it will finally be deleted. The customer is told what was kept and why.

Does crypto shredding work for data that analysts have already joined into aggregated tables?

Aggregates such as daily revenue per country do not identify a person, so they can usually stay. The risk is in derived tables that still hold a row per customer. Those must either be rebuilt from erased sources or included in the warehouse deletion job, which is why the inventory must cover derived datasets and not only source tables.

How do we handle erasure in search indexes and caches?

They are stores like any other and belong in the inventory. Caches should have a short TTL, so they expire on their own, and search indexes subscribe to the same erasure event and delete the customer's documents. The ledger waits for them to confirm like every other store.

8Conclusion

In this answer, we saw that erasure is a flow through the whole platform. A data inventory names every store and its erasure method, personal data is kept apart from business facts, and crypto shredding with a key per customer makes copies we cannot edit unreadable. Kafka uses tombstones on compacted topics or short retention, backups are limited in time and re-erased from a deletion log on restore, the warehouse runs deletion jobs from the same erasure event, and a ledger records each store's confirmation as evidence.

What to say in the interviewAbout 80 seconds aloud

Open with

I would start with a data inventory: every store that holds personal data, which fields, who owns it and how erasure happens there. Then I would separate personal fields from business facts, so orders and invoices refer to a pseudonymous customer id, and encrypt the personal fields with a key per customer held in a key management service.

Then, if they want more

On an erasure request the key is destroyed, which is crypto shredding: every copy in backups, archives and old topic segments becomes unreadable at once.

For Kafka, state topics are compacted and keyed by customer id, so a tombstone removes the customer after compaction, with max compaction lag set to bound the time, and event topics keep short retention and carry only the pseudonymous id. Backups have a limited retention, around 35 days, and a deletion log of erased ids is replayed after any restore.

The warehouse runs a deletion job that consumes the same erasure event and covers derived tables, with time travel shorter than our deadline. Every store reports back to an erasure ledger, so we can show auditors that each request completed within the one month GDPR allows, and we keep invoice facts where the law requires it.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "GDPR requires erasing a customer's personal data on request, but data also lives in...": https://scrivio-interview-library.netlify.app/databases/analytics-and-cdc/ede4370b8c/