SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
  • SSL/TLS
  • Encryption at Rest
  • Secrets Management
  • Password Management
  • RBAC
  • SAML
  • OWASP Top 10 and Common Attacks
  • DDoS Attacks and Defenses
  • Web Application Firewall (WAF)
  • Certificates and PKI
  • Multi-Factor Authentication (MFA)
  • Zero Trust
  • Key Management (KMS)
  • Data Privacy and GDPR Basics
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Operations and Security/Advanced Security

Data Privacy and GDPR Basics

Collect less, protect it, let people see and erase their data: the engineering side of privacy law.

⏱ 13 min readIntermediateInterview FavouriteHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

Data privacy is about handling information on real people with care: collect only what you need, keep it safe, use it only for the reason you gave, and let people see and erase it. GDPR is the European Union law that turns these ideas into duties, and many other laws (such as California's CCPA) follow similar lines.

  • For engineers it means design: know where personal data lives, limit it, protect it, and be able to find and delete it everywhere.
  • The hard part is the copies: replicas, caches, search indexes, data lakes, logs, event streams, backups and vendors.
  • Privacy by design: build these abilities in from the start, not as a late patch.
πŸ“Not legal advice
This page is an engineering overview at a basic level. Laws differ by country and change over time. Always check the real rules with your legal or privacy team.

02Concept: What is it?

Personal data is any information that can identify a person, directly or together with other data: a name, email, phone number, IP address, device ID, location or account number. Sensitive (special category) data needs extra care: health, biometrics, religion, political views, and so on. The company deciding why and how data is used is the controller. A company handling it on the controller's behalf, such as a cloud or analytics vendor, is a processor.

GDPR says you need a lawful basis to use personal data: for example consent, a contract, a legal duty or a legitimate interest. People (data subjects) also get rights: to access their data, correct it, have it erased, receive a copy in a portable form, and object to some uses.

The principles behind the rules
Collect
πŸͺΆMinimisationonly what you need
🎯Purpose limitationonly for the stated reason
Keep
⏳Storage limitationdelete when no longer needed
βœ…Accuracykeep it correct
Protect and prove
πŸ”Integrity and confidentialitysecurity
πŸ“’Accountabilitybe able to show it
These shape the system design more than any single article of the law.
🧠Privacy is not the same as security
Security stops the wrong people from reading data. Privacy also asks whether you should have the data at all, why you use it, and how long you keep it. A perfectly secure system can still break privacy rules by collecting too much.

03Real-Life Example

🍡The Library Card and the Photocopies
You give a library your details to get a card. You expect them to ask only what they need, use it only for lending, keep it safe, show you your record when asked, and tear it up if you leave. Now imagine the librarian made photocopies for the back office, the newsletter team, an outside mailing company and a safe-deposit box. Asking the library to "delete my record" only works if they remember every copy. That is the engineering side of privacy.
Library
Privacy engineering
Asking only what is needed
Data minimisation
Using it only for lending
Purpose limitation and consent
Showing you your record
Right of access
Tearing up your card on request
Right to erasure
A list of every place a copy sits
Data map and inventory
Copies in a back office and a mailing firm
Replicas, backups and third-party processors
Telling you if a file is lost
Breach notification

04Why Do We Need It?

βš–οΈIt is the law
Fines under GDPR can be very large, and other regions have similar laws.
🀝User trust
People choose products that treat their data with respect.
πŸ’₯Smaller breaches
Data you do not keep cannot be stolen. Less data means less harm.
🧹Lower cost
Less stored data means less storage, less backup and less to search.
🌍Market access
Enterprise buyers ask for privacy proof before they sign.
🧩Cleaner design
A known data map and clear ownership make the whole system easier to run.
The best privacy control is to not collect or keep data you do not need.

05Where Do We Use It?

πŸ›’Accounts and checkout
Names, addresses, payment details and order history.
πŸ“ˆAnalytics and tracking
Page views, device IDs and cookies often need consent.
πŸ₯Health and finance
Sensitive data with extra rules and stricter retention.
πŸ€–ML and feature stores
Training data may contain personal data that must be controlled.
πŸͺ΅Logs and traces
IP addresses, emails and IDs often leak into logs by mistake.
🏒Multi-tenant SaaS
You are a processor for your customers, who are the controllers.

06Types / Parts / How It Works

The rights people have (basic list)

RightIn plain wordsWhat engineering needs
AccessShow me what you hold about meFind all of a person's data across systems and export it
RectificationFix wrong dataUpdate in the source and all derived copies
ErasureDelete my data (the 'right to be forgotten')Delete or anonymise in every store, with exceptions where law requires keeping it
PortabilityGive me my data in a usable formatExport in a common machine-readable format such as JSON or CSV
Objection / restrictionStop using my data for some purposesFlags and filters that downstream jobs respect
Withdraw consentI changed my mindA consent record that is checked before each use

Pseudonymisation vs anonymisation

TechniqueWhat it doesStill personal data?
PseudonymisationReplace identifiers with a code. A separate key table links backYes. It lowers risk but can be reversed
AnonymisationRemove or change data so a person can no longer be identified, even with other dataNo, if it is truly irreversible. This is hard to do well
EncryptionScramble data so only key holders can read itYes, while the key exists
AggregationKeep only totals and averagesOften no, but small groups can leak identity

Where one person's data hides

One person, many copies
πŸ§‘A person
→↓stored in
πŸ—„οΈDatabase + replica
⚑Cache
πŸ”ŽSearch index
🌊Data lake
πŸ“œEvent log
πŸ’ΎBackups
An erasure request must reach all of them.
Easy to delete Needs a purge Hard: immutable
VisualizerA β€œdelete my data” request across eight storesPress the delete button with only the primary database mapped, and see how many copies are missed. Then map more stores, or turn on data minimisation, and watch the risk fall.
Which stores has your team inventoried and automated?
After the request: green = erased, red = still holds the person's data.
πŸ—„οΈ
Primary database
holds data
πŸͺž
Read replica
holds data
⚑
Cache
holds data
πŸ”Ž
Search index
holds data
🌊
Data lake
holds data
πŸ“œ
Event log
holds data
πŸ’Ύ
Backups
holds data
πŸ“ˆ
Third-party analytics
holds data
Stores holding data
8
before minimisation
Copies erased
-
Copies missed
-
Compliance risk
-
A user asks to be deleted. First choose which stores your team has mapped and automated, then press the button. The default team only knows about the primary database.

An illustration, not legal advice. The weights and stores are examples, and real systems have more copies than eight. What counts as β€œerased” and how fast depends on your law and your lawyers.

07How to Use It / Steps / Implementation

Building privacy into a system

  1. 1
    Map the data
    Keep an inventory: what personal data you hold, where it lives, why, who can see it, and how long you keep it.
  2. 2
    Minimise
    Do not collect fields you do not need. Do not send personal data to vendors or logs without a reason.
  3. 3
    Tag and classify
    Mark personal and sensitive fields in schemas, so code and pipelines can treat them differently.
  4. 4
    Separate identity from activity
    Use a user ID, not an email, in events and analytics. Keep the identity table in one protected place.
  5. 5
    Set retention
    Give each data type a lifetime, and delete or archive it on schedule with TTLs and jobs.
  6. 6
    Build erasure and export
    One workflow that fans out to every store, tracks status and writes an audit record.
  7. 7
    Handle immutable stores
    For event logs and backups, use per-user encryption keys (crypto-shredding), tombstones, or short retention.
  8. 8
    Manage consent
    Record what each person agreed to and when, and check it before each use.
  9. 9
    Prepare for breaches
    Have a plan. Laws such as GDPR can require telling the authority within a short time (72 hours in many cases). Ask your legal team for the rules that apply to you.
πŸ’‘Delete by key
For data that is hard to edit (events, backups, data lakes), encrypt each person's data with their own key. To erase them, destroy the key. See Key Management (KMS).
⚠️Some data must be kept
Erasure has exceptions, such as tax records or legal claims. Your system needs a way to hold some data while still removing it from other uses.

08Key Terms to Know

TermMeaning in easy words
Personal dataAny information that can identify a person, alone or combined
Sensitive dataSpecial categories such as health, biometrics or beliefs, with extra rules
Data subjectThe person the data is about
ControllerDecides why and how personal data is used
ProcessorHandles personal data on the controller's behalf
Lawful basisThe legal reason for using data, such as consent or contract
Data minimisationCollecting and keeping only what is needed
Purpose limitationUsing data only for the reason you gave
Right to erasureThe right to have personal data deleted, with exceptions
PseudonymisationReplacing identifiers with codes, reversible with a key
AnonymisationMaking identification impossible, irreversibly
DPIAData protection impact assessment, done before risky processing
Data residencyRules about the country where data is stored or processed
Crypto-shreddingErasing data by destroying its encryption key

09Pros, Cons and Trade-offs

βœ… Pros
  • Builds trust with users and buyers
  • Reduces the damage of a breach
  • Forces a clear map and ownership of data
  • Lowers storage and processing cost
  • Avoids fines and legal trouble
⚠️ Cons
  • Adds engineering work for inventory and erasure
  • Copies in backups and logs are hard to remove
  • Rules differ by country and change over time
  • Anonymisation is difficult to get right
  • Can slow down analytics and machine learning

Trade-offs

ChoiceWe gainWe lose
Collect lessLess risk and costLess data for product and analytics
Short retentionLower exposureLess history for audits and debugging
Per-user keysEasy erasure everywhereMany keys, more KMS load
PseudonymiseSafer analyticsStill personal data, keys must be guarded
Keep data in one regionSimpler residencyHigher latency for far users, less redundancy

10Common Problems and Mistakes

Common mistakes

  1. No data map. You cannot protect or delete what you cannot find.
  2. Deleting only from the main database. Replicas, caches, indexes, lakes and vendors still hold the person.
  3. Personal data in logs. Emails, tokens and IP addresses end up in files kept for months.
  4. Treating pseudonymised data as anonymous. It is still personal data while a link back exists.
  5. Collecting "just in case". Extra fields become extra liability.
  6. Forgetting vendors. Analytics, email and support tools hold copies. They need contracts and deletion calls.
  7. Consent as a one-time box. Withdrawal must be honoured downstream.

Things to watch

πŸ’ΎBackups
You usually cannot edit a backup. Keep them short, or record deletions and re-apply them after a restore.
πŸ“œImmutable logs
Event sourcing and audit logs resist change. Use crypto-shredding or avoid personal data in events.
🌍Cross-border
Moving data between countries may need extra legal steps. Check with legal.
🧠ML models
Models trained on personal data raise open questions about erasure. Keep training data governed.

11Real-World Examples

πŸ‡ͺπŸ‡ΊGDPR
The EU law in force since 2018. It covers organisations anywhere that handle data of people in the EU.
🌴CCPA / CPRA
California laws with similar ideas: know, delete and opt out of the sale of data.
πŸͺCookie banners
A visible form of consent management for tracking.
πŸ“€Download your data
Many services offer an export tool, which is the right of access and portability in practice.
πŸ—‘οΈAccount deletion flows
A request that fans out to databases, search, analytics and email vendors, then confirms.
πŸ”Per-user encryption
Some systems keep a key per user so that erasure is destroying one key.
Mini case: erasure with an event log
πŸ“œEvent logpayloads encrypted per user
→↓user asks to be erased
πŸ—οΈDestroy user key
→↓events become noise
βœ…Log intact, person gone
Per-user keys make an append-only log erasable.

12Related Topics to Read Next

Data Governance and Feature Stores→

Ownership, classification and lineage make privacy possible.

Audit Logs→

Proof that a request was handled.

Encryption at Rest→

Protects stored personal data.

Key Management (KMS)β†’

Crypto-shredding for hard-to-edit stores.

Multi-Tenancy→

You may be a processor for many customers.

Data Lakes→

Where raw personal data often piles up.

Data Archiving and TTL→

Retention and expiry rules in practice.

Event Sourcing→

An immutable log that makes erasure tricky.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • βœ”Privacy: collect less, protect it, use it for the stated reason, delete it on time.
  • βœ”Rights: access, fix, erase, port, object, withdraw consent.
  • βœ”Start with: a data map and ownership.
  • βœ”Erasure: fan out to DB, replicas, cache, search, lake, events, backups, vendors.
  • βœ”Immutable data: per-user keys and crypto-shredding.
  • βœ”Logs: keep personal data out of them.
  • βœ”Pseudonymised is still personal. Anonymised is not.
  • βœ”One line: β€œThe best data to protect is the data you never kept.”
← Previous
Key Management (KMS)
Next β†’
Requirements Gathering