BXUP Track progress & test yourself — free
Database & ERP · Playbook · Core · ~5 min read
DATABASE & ERP · PLAYBOOK · CORE

Map PII in OLTP and Draft the Masking Plan

You cannot protect columns you have not found, and PII hides in notes fields and custom_attr_7 far more than in columns named ssn. This playbook layers engine-native discovery with an LLM classification pass over metadata and profiled shapes, producing a PII map and masking plan mapped to DPDP and GDPR obligations.

Tier: Core · Workflow area: Security & Compliance · ~35 minutes

Engine-native classifiers (SQL Server Data Discovery & Classification, Oracle Data Safe, open-source scanners) find the obvious: columns whose names or formats scream email, phone, card number. The residue they miss is where breaches live — free-text fields holding pasted addresses, misused generic columns, legacy imports. An LLM is genuinely good at the residue, because classification from names, comments and value shapes is a language task. The design constraint is that classification must not itself become the leak: the model sees metadata and profiled patterns, not raw rows, unless it is a tenant-approved model cleared for that data.

When to use

  • DPDP/GDPR compliance groundworkdata-mapping obligations need an inventory of personal data by system, and OLTP is where it concentrates.
  • Before masking lower environmentsdev/test refreshes from production are the classic uncontrolled PII copy; the map decides what the refresh pipeline must mask.
  • Before AI features touch the databaseRAG, NL-to-SQL and MCP surfaces (pb-33/34/35) all need to know which columns must never appear in a model's context.

When NOT to use

  • By pasting raw rows into an external assistantclassifying PII by exfiltrating PII is the project failing itself. Metadata, shapes and synthetic examples only, unless the model is tenant-approved for the data class.
  • As a legal determinationthe map informs counsel and the DPO; what legally counts as personal data under DPDP or GDPR in your context is their ruling, not the model's.
  • For unstructured stores in scopedocument blobs and object storage need dedicated scanning tooling; this playbook owns relational OLTP.

The recipe

  1. Run the engine-native pass first — it is free signal.

    -- SQL Server: built-in discovery
    -- SSMS: Tasks > Data Discovery and Classification > Classify Data
    -- or query existing labels:
    SELECT schema_name, table_name, column_name,
           label, information_type
    FROM sys.sensitivity_classifications sc
    JOIN sys.columns c ON c.object_id = sc.major_id
                      AND c.column_id = sc.minor_id
    JOIN sys.tables t ON t.object_id = c.object_id
    JOIN sys.schemas s ON s.schema_id = t.schema_id;
    

    On Oracle, run Data Safe's sensitive-data discovery job. On Postgres, there is no native equivalent — the profiling in step 2 carries more weight.

  2. Profile shapes, not values, for the LLM pass. Build a metadata-plus-shape extract that describes every column without containing any actual row:

    -- Postgres example: shape profile per text column
    SELECT c.table_name, c.column_name, c.data_type,
           col_description(format('%I.%I', c.table_schema,
             c.table_name)::regclass, c.ordinal_position) AS comment,
           (SELECT COUNT(DISTINCT x) FROM (SELECT substring(t.col from
             '^[A-Za-z0-9@.+-]{0,5}') x FROM tbl t LIMIT 1000) s)
           AS prefix_cardinality  -- illustrative; use a profiler
    FROM information_schema.columns c WHERE c.table_schema = 'public';
    

    In practice use a profiling script that emits, per column: name, type, comment, null rate, distinct rate, min/max length, and a regex-generalized pattern of sampled values (aaa@aaa.aa, +91-ddddd-ddddd, dddd dddd dddd dddd) — shapes that classify without disclosing.

  3. Ask the LLM to classify the residue and challenge the native labels.

    Below: (a) engine-native classification results, (b) a shape profile
    of every column (name, type, comment, null/distinct rates, length
    stats, generalized value patterns). No real values are included.
    
    Produce a PII map:
    1. For every column, classify: direct identifier / quasi-identifier /
       sensitive-special-category (health, biometrics, financial) /
       not personal data / CANNOT DETERMINE. Give a one-line reason
       citing the evidence (name, comment, or pattern).
    2. Flag columns the native scan missed but the shapes suggest —
       especially free-text and generic columns whose patterns contain
       email/phone/ID shapes.
    3. Flag native labels the shapes contradict.
    4. List quasi-identifier COMBINATIONS in the same table that jointly
       re-identify (e.g., dob + pincode + gender).
    
    Be conservative: prefer CANNOT DETERMINE over confident guesses.
    

    The combination analysis in point 4 is something native scanners do not attempt and regulators increasingly expect.

  4. Verify the flags with targeted, in-boundary queries. Every CANNOT DETERMINE and every LLM-only flag gets a human check run locally — the raw values stay in the database:

    -- Does the free-text notes field actually contain email addresses?
    SELECT COUNT(*) FROM support_tickets
    WHERE notes ~ '[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}';
    
    -- Phone shapes in a generic column?
    SELECT COUNT(*) FROM entity_attributes
    WHERE attr_key = 'custom_attr_7'
      AND attr_value ~ '^\+?[0-9][0-9 -]{8,14}$';
    

    A result like support_tickets.notes: 12,481 rows matching email pattern upgrades a hypothesis into a finding with a number on it.

  5. Draft the masking plan, column by column, technique by technique. With the verified map, have AI draft the plan — then review it as the DBA who must keep referential integrity alive. Each row of the plan: column, classification, environments in scope (prod stays, lower environments mask), technique, and the integrity note. Techniques by class: deterministic tokenization for join-key identifiers (email as key must mask consistently across tables), format-preserving randomization for phones/cards where app validation runs, nulling or fixed literals for free-text, generalization for quasi-identifier combinations (dob → birth year). The classic failure the review must catch: masking customers.email randomly while orders.customer_email masks differently, silently breaking every join the test suite relies on.

  6. Map to obligations and hand the DPO a decision document. Final artifact: the PII map with per-column verification status, the masking plan, and an obligations column drafted by AI (DPDP: personal data — notice + purpose limitation; GDPR Art. 9 if health-related) marked explicitly as draft for DPO review. The DPO rules on the law; you rule on the columns.

Make it yours

  • SQL Serverpersist agreed labels into sys.sensitivity_classifications (ADD SENSITIVITY CLASSIFICATION) so audit logging picks them up; Dynamic Data Masking can implement parts of the plan but is access-convenience, not security — say so in the plan.
  • OracleData Safe discovery feeds Data Masking packs; the LLM residue pass still earns its place on free-text and custom columns Data Safe's patterns miss.
  • Postgrespair the map with pgAnonymizer/pg_anon-style tooling for lower-environment refreshes; declare masking rules as SECURITY LABELS or a rules file kept in the same repo as the map.

Quality check

  • No raw rows reached an external modelthe extract was audited before sending: names, stats and generalized patterns only. This check is absolute.
  • Every LLM flag was verified with an in-boundary querycounts on real data, run by you. The map's authority comes from these numbers, not from classification confidence.
  • Quasi-identifier combinations were assessed, not just single columnsthe map has a section for them, or it is incomplete.
  • Masking preserves referential integrity by designdeterministic techniques on every join-key identifier, verified by running the app test suite against a masked refresh.
  • The DPO signed the obligations mappingthe legal column carries a human ruling, with the AI draft retained as draft.
Warning

The finished PII map is itself a sensitive document — a guided tour of where your most valuable data sits. Store it access-controlled with the security team, version it, and treat "who can read the PII map" as part of the review it documents.

Key Takeaway:

Native scanners find the labeled PII; the LLM pass finds where PII actually hides — free text, generic columns, re-identifying combinations — and it can do so from shapes alone, without touching a single real row. Verify every flag with a local query, mask with join-keys deterministic, and let the DPO own the law.

This is the free reading view. Open BXUP to track your progress, run the hands-on labs, and prove it with original, exam-pattern assessments.
© Anvi Innovate · BXUP — Be Exponentially Upskilled · BXUP is an independent learning platform, not affiliated with or endorsed by AWS, Microsoft, Google, NVIDIA, IBM, Salesforce, Databricks, Oracle or Anthropic. All trademarks belong to their respective owners. · bxup.in