Design a Multi-Source Data Reconciliation Pipeline
System DesignModel answerLast updated
Design and implement a pipeline that merges messy person records from several sources into canonical entries, handling normalization, matching, conflict resolution, and validation.
You are building a system that takes in person records from several independent data sources and reconciles them into a clean, deduplicated dataset. Each record contains fields like name, email, phone, and address, but the data is noisy: values may be missing, inconsistently formatted, abbreviated, or even contradictory across sources. There is no shared primary key linking records between sources.
Your system must accomplish four things:
- Determine whether any two given records describe the same real-world individual.
- Cluster all records belonging to the same person into groups.
- Produce one canonical record per group by merging the available information.
- Keep records that have no match as standalone groups of size one.
You should be explicit about the following design decisions:
- Field normalization: How do you clean each field type before comparison? Consider case differences, phone number formatting, address abbreviations, and name variations (nicknames, initials, middle names).
- Matching strategy: What rules or scoring mechanism do you use to decide that two records refer to the same person? How do you weigh strong signals (exact email match) versus weaker composite signals (name plus address)? How do you handle negative evidence where non-null fields directly contradict each other?
- Conflict resolution: When grouped records disagree on a field value, which value wins? Consider source authority, recency, and majority voting.
- Quality validation: How would you measure precision and recall of your matcher? Would you introduce a manual-review band for borderline cases?
Constraints
- Input is a list of records, each tagged with a
sourcelabel and ideally alast_updatedtimestamp. - False positives (merging two distinct people) are more costly than false negatives (leaving one person split across groups), since silent over-merging corrupts data and is difficult to reverse.
- The dataset is large enough that comparing every pair of records is prohibitively expensive. You must address throughput and candidate generation, not just correctness on a small example.
- Fields are free-text and unstructured: emails may vary only in casing, phone numbers may include or omit country codes and separators, addresses use inconsistent abbreviations, and names may appear as full names, nicknames, or initials.
Clarifying Questions to Ask
- Is a wrong merge considered worse than a missed merge, and is a manual-review threshold for borderline matches acceptable?
- Are any sources considered authoritative (such as a verified or KYC source) whose values should take precedence on conflict? Is
last_updateda reliable recency signal? - What scale are we targeting — thousands or tens of millions of records — and is this a batch process over a snapshot or an incremental stream?
- Which fields serve as reliable identifiers in this domain? Is email or phone truly unique per person, or might they be shared? Are there additional fields not listed (date of birth, account ID) that could help?
- Is there a labeled ground-truth dataset to measure against, or do we need to bootstrap one?
Hints
Hint 1
Start by normalizing each field independently before any comparison — this step alone resolves many near-duplicates deterministically.
Hint 2
Avoid all-pairs comparison by generating candidate pairs through blocking: group records by a shared key (like a normalized email prefix or phone hash) and only compare within blocks.
Hint 3
Use a tiered scoring system: strong signals like exact email or phone match can auto-merge, composite signals like name plus address contribute partial confidence, and contradictory non-null fields reduce the score.
Hint 4
Group matched pairs using connected components (union-find) to handle transitivity, but watch for weak edges chaining unrelated records together.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
A strong approach treats this as a multi-stage pipeline where each stage is independently testable and the precision-recall trade-off is managed explicitly.
Stage 1: Normalization
Before any comparison, normalize each field deterministically:
- Names: lowercase, strip punctuation, expand common nicknames (Bob → Robert) using a lookup table, drop middle initials, and sort tokens so "John Smith" and "Smith, John" align.
- Emails: lowercase, strip whitespace, and ignore plus-addressing aliases (user+tag@domain → user@domain) if the domain supports it.
- Phones: strip all non-digit characters, normalize to E.164 or a consistent national format, and handle missing country codes with a default region.
- Addresses: uppercase, expand abbreviations (St → Street, Ave → Avenue), normalize zip codes to five digits, and standardize unit and apartment formatting.
Normalization is applied once and stored alongside the original values so provenance is never lost.
Stage 2: Candidate Generation (Blocking)
An all-pairs comparison at O(n²) is infeasible for large datasets. Use blocking to generate candidate pairs: partition records into buckets by a shared blocking key and only compare records within the same bucket. Common blocking keys include the first three characters of a normalized last name, a normalized email domain plus local-part prefix, or a phone area code plus last four digits.
Blocking trades recall for speed — if two matching records land in different blocks, the match is missed. To mitigate this, use multi-pass blocking with several independent keys and union the candidate pairs. Blocking keys should be chosen so that the within-block comparison count stays manageable, roughly O(n × k) where k is the average block size.
Stage 3: Scoring and Matching
For each candidate pair, compute a match score using a tiered rules engine:
- Strong signals (auto-match): exact normalized email match, or exact normalized phone match combined with a name token overlap. These carry high confidence.
- Composite signals (contribute partial weight): name similarity via Jaro-Winkler or token-based Jaccard, address similarity, overlapping partial phone or email. Each contributes a weighted score.
- Negative evidence (reduces confidence): two records both have non-null values for the same field that disagree after normalization (different emails, different phone numbers with no overlap). Strong contradictions lower the score significantly.
Define three thresholds:
- Auto-merge (score ≥ high threshold): accept the match.
- Review band (medium threshold ≤ score < high threshold): flag for manual review.
- No match (score < medium threshold): reject.
This three-band design directly addresses the cost asymmetry. A conservative high threshold prevents false positives; the review band catches borderline cases that a human can adjudicate.
Stage 4: Grouping via Connected Components
Treat each auto-merged pair as an edge in a graph and compute connected components (union-find is efficient and simple). Every component becomes a group. This handles transitivity: if A matches B and B matches C, all three end up in the same group.
The over-merging risk is real: a chain of weak edges can merge unrelated records. To mitigate this, either require that the minimum edge weight in any path stays above a floor, or run a second pass that checks the diameter of each component and splits groups that are too internally inconsistent (e.g., two sub-clusters connected by a single weak edge).
Stage 5: Canonical Record and Conflict Resolution
For each group, produce one merged record:
- Precedence policy: if a source is authoritative (verified/KYC), its values win on conflict. Otherwise, prefer the most recently updated record (
last_updated), then majority vote across the group, then the longest non-empty value. - Missing field filling: if one source has a value and another does not, take the non-null value.
- Provenance: store the source and timestamp for every field value in the canonical record, so any decision can be audited and reversed.
Stage 6: Validation
- If a labeled dataset exists, measure precision (of merged pairs, how many are correct) and recall (of all true matches, how many were found) separately. Accuracy alone is misleading because unmatched pairs dominate.
- If no labels exist, bootstrap a gold standard by sampling candidate pairs and manually labeling a few hundred, then use that to calibrate thresholds.
- Log the reason for every match decision (which signals fired, what score was computed) so that errors can be traced and the rules iteratively improved.
- Run regression tests with fixtures covering each dirty case (case-only email difference, nickname, abbreviated address, contradictory phone) to ensure normalization and scoring behave as expected.
Complexity
- Normalization: O(n) per field, O(n) total.
- Blocking: O(n) to assign keys, O(n × k) for within-block comparisons where k is average block size.
- Scoring: O(P) where P is the number of candidate pairs, which should be roughly O(n × k).
- Union-find: O(P × α(n)) where α is the inverse Ackermann function, effectively constant per operation.
- Merge: O(n) to produce canonical records.
Overall throughput is linear in the number of records times the average block size, which is the key property that makes this approach scale.
Common Mistakes
- Comparing raw values without normalization, causing near-duplicates to be missed.
- Using a single similarity threshold with no review band, forcing an all-or-nothing decision on borderline pairs.
- Ignoring negative evidence, so two records with contradictory emails still merge because names match.
- Not retaining provenance, making it impossible to audit or undo a bad merge.
- Treating this as a single function rather than a pipeline, which makes it untestable and hard to tune.