Video in progress
When audit log requirements and user data deletion requirements (for example the "right to be forgotten") conflict, how do you design the system?
I separate personal data (PII) from business records: audit and financial records link to the user through a pseudonym id, while PII lives separately and can be deleted. If needed, a separate encryption key per user: delete the key and the data becomes unreadable in every copy (crypto-shredding). Legal retention periods are defined separately.
📖 Answer
The requirements pull against each other: audit wants to keep "who did what, when" unchanged for a long time; privacy requires deleting a user's personal data when they ask; and financial law forces you to keep transactions for years.
The design:
-
Data classification. Each field is PII (name, phone, address), business (order amount) or technical. The classification should live in code too (an annotation) and be used automatically in logs and exports.
-
Pseudonymization. An audit record says
actor = user_8f3a..., while the name and phone are in a separatepersontable. On a deletion request,personis deleted or anonymized; the audit stays whole, it just no longer links to that person. -
Crypto-shredding. PII is encrypted with a separate key per user (in a KMS). Even if the data has spread across backups, Kafka topics and a data lake, deleting the key makes all of it unreadable. Otherwise, finding and deleting every copy is nearly impossible.
-
Retention policy: a period and a legal basis for each type of data, and jobs that automatically clean up what has expired.
-
Limit the spread: no PII in logs (masking), only ids in events, anonymized data for analytics.
-
Deletion happens across services: a
UserErasureRequestedevent, each service does its part and confirms, the process is tracked and a report is kept.
Legal requirements depend on the country, so define them together with lawyers. The architecture should make meeting them cheap.
Sign up to mark studied questions and save your progress.