Scrivio Interview library
LeadershipPrincipal7 min read · updated 12 November 2026

Your company has duplicate customer records spread across CRM, billing, support and marketing systems. Finance estimates the cost in wrong invoices and double mailings at several million a year, and each team runs its own dedupe scripts. What long-term approach do you set?

I would treat this as a master data problem rather than a cleanup problem: name a system of record and an owning team for customer identity, agree the matching and survivorship rules, and prevent duplicates at entry with normalized unique keys, idempotency keys and a matching service. Matching would be bought or built on cost, merges kept reversible and audited, and progress tracked with a few metrics funded against the measured loss of several million a year.

Why this question is asked

When every team runs its own dedupe script, the company pays four times for the same work and still gets four different answers to the question "who is this customer?". Finance's estimate of several million a year in wrong invoices and double mailings turns a data-quality annoyance into a business case. Interviewers ask this leadership question to see whether we can move from fixing symptoms to fixing the system, and whether we know where the real risks lie, including the risk of merging people who are not the same. In this answer, we will name the actual problem, set ownership and identity rules, move prevention to the point of entry, choose how to do matching, make merges safe, and decide how to measure and fund the work.

1Naming the Real Problem

Duplicates in CRM, billing, support and marketing are not four problems. They are one missing decision: there is no agreed answer to which record is the real customer, and no single place that holds that answer. Master data is the core business data many systems share, such as customers, products and suppliers, and master data management (MDM) is the discipline of keeping one trusted version of it. Each team's script cleans its own copy by its own rules, so the systems drift apart again and even disagree with each other after the cleanup.

So the first leadership move is to stop treating it as a series of SQL jobs and start treating it as a capability with an owner, rules and tooling. That reframing is what makes the rest possible.

2Ownership, System of Record and Identity Rules

We decide which system is the system of record for customer identity, the place where a customer is created and where the authoritative identity lives, or we introduce a customer hub whose job is exactly that. Every other system keeps its own records but links them to a single customer id from the hub. A named team owns the hub, the rules and the data quality, with data stewards who resolve uncertain cases.

The identity rules say when two records are the same customer. They usually combine deterministic rules, such as the same normalized email or the same tax id, with probabilistic ones, such as a similar name at the same normalized address. Survivorship rules say which value wins when merged records disagree: perhaps billing's address because it is verified by payments, and marketing's consent flags because they are legally binding there.

SQL
-- The hub links every source record to one customer id
CREATE TABLE customer_xref (
source_system text NOT NULL, -- 'crm', 'billing', 'support', 'marketing'
source_id text NOT NULL,
customer_id bigint NOT NULL, -- the golden record
linked_at timestamptz NOT NULL,
rule text NOT NULL, -- 'email_exact', 'name_address_0.93', 'steward'
PRIMARY KEY (source_system, source_id)
);
SELECT source_system, source_id FROM customer_xref WHERE customer_id = 1042;
-- crm | C-77812
-- billing | 300441
-- support | 5521
Step throughCustomer master data
  1. CRM, billing, support, marketingkeep their own records, store the customer id
  2. Matching servicecheck before create, return existing customer
  3. Customer hubgolden record, cross-reference, merge history
  4. Identity and survivorship rulesowned by one team, reviewed with stewards

4 layers, from the top down. Step through them one at a time.

3Preventing Duplicates at the Point of Entry

The cheapest duplicate is the one never created. Each system that creates customers calls the matching service first: "does this person already exist?". If there is a confident match, it uses the existing customer id; if the match is uncertain, it creates the record but flags it for a steward. Inside each database, unique constraints on normalized keys, such as a unique index on lower(email), stop exact duplicates even when two requests race. Create APIs accept an idempotency key, so a client that retries a timed-out sign-up gets the same customer back instead of a second one.

This is where the long-term savings come from. After-the-fact deletes will always be needed for some edge cases, but if most new duplicates stop at entry, the backlog shrinks every month instead of growing.

4Matching: Build or Buy

Good matching is harder than it looks. Names have nicknames, typos and transliterations, addresses have many formats, and emails change. A production matcher needs normalization, fuzzy comparison, blocking (comparing only plausible candidate pairs, so we do not compare every record with every other), scoring with thresholds, and a steward queue for the middle band.

Commercial MDM tools provide all of this, plus survivorship configuration and steward user interfaces. They cost licences and integration work. Building in-house gives control and fits our data, but the four existing scripts show what in-house matching tends to become. I would compare the real costs: the people time spent on today's scripts plus the projected build, against the licence plus integration. At several million a year in losses, a tool that costs a fraction of that and reduces duplicates sharply is often the cheaper option, and I would decide with a proof of concept on a sample of our real records, measuring precision and recall of the matches.

5Keeping Merges Reversible and Auditable

A wrong merge is worse than a duplicate. If two different people named Ana Silva are merged, one of them may see the other's invoices, address and support history, which is a privacy breach in most jurisdictions, and both may receive wrong bills. So merges must never destroy data: the hub keeps the source records and the merge history, who or which rule merged them, when and why, so any merge can be undone.

Step throughHandling a candidate match
  1. Score the candidate pairdeterministic and fuzzy rules
  2. Score above 0.95?
    YesMerge automatically, record historyNoCheck the middle band
  3. Score between 0.80 and 0.95?
    YesSend to a data stewardNoKeep as separate customers
  4. Merge recordedrule, time, source records kept for unmerge

4 steps in order. Play them, or step through them one at a time.

The thresholds follow from this asymmetry. Automatic merges only above a high confidence score, steward review in the middle band, and no merge below it. Merges that would combine records with different tax ids or dates of birth are blocked outright.

6Measuring and Funding the Work

Finally, a few metrics keep the effort honest. The duplicate rate, the share of new customers that turn out to match an existing one, shows whether prevention works. The merge backlog, candidate pairs waiting for a steward, shows whether the team keeps up. Cost incidents, wrong invoices and double mailings traced to duplicates, connect the work to finance's estimate. We measure the baseline before starting, set targets such as halving the duplicate rate in a year, and report against the measured loss. That lets us fund the programme as an investment with a return, rather than as one more cleanup project competing for spare time.

7Follow-up questions

How would you handle a wrong merge reported by a customer?

As an incident. We unmerge using the merge history, restoring both source records and their links, check what data each person could see or was sent while merged, and involve the privacy team if personal data was disclosed. Then we find the rule or steward decision that caused it, fix it, and add the pair to the test set for the matching rules.

Should every system stop creating customers and call the hub instead?

Ideally new customers are created through the hub's API, but that can take time. A practical first step is check-before-create through the matching service plus nightly linking of new records, moving systems to hub-first creation one by one.

Why not just run one central dedupe job instead of four?

It would be better than four, but it is still cleanup after the damage. Without prevention at entry and an owner for identity rules, the job runs forever, and the systems still disagree between runs.

8Conclusion

In this answer, we treated duplicate customers as a master data problem: a system of record or customer hub, identity and survivorship rules owned by a named team, and links from every system to one customer id. We moved prevention to the point of entry with unique constraints on normalized keys, idempotency keys and a matching service, chose to build or buy matching based on real costs and a proof of concept, kept merges reversible and auditable because wrong merges harm customers and may breach privacy rules, and tracked the duplicate rate, merge backlog and cost incidents to fund the work against the measured loss.

What to say in the interviewAbout 90 seconds aloud

Open with

I would stop treating this as a cleanup task and treat it as master data management. The real issue is that nobody owns the answer to who is this customer, so each team cleans its own copy with its own rules and the systems drift apart.

Then, if they want more

First, I would name a system of record or a customer hub, and a team that owns the identity rules and survivorship rules, which decide when two records are the same person and which value wins. Every system links its records to one customer id through a cross-reference.

Second, prevention at the point of entry: check-before-create through a matching service, unique constraints on normalized keys like lowercased email, and idempotency keys on create APIs so retries do not create new customers.

Third, matching itself is hard, with fuzzy names and addresses, so I would compare building it against a commercial MDM tool on real costs, including the people time the current scripts take, and run a proof of concept on our data measuring match quality.

Fourth, merges must be reversible and audited, because a wrong merge can show one person's invoices to another, which is a privacy breach; so automatic merges only at high confidence, stewards for the middle band.

Finally, I track the duplicate rate, the merge backlog and cost incidents against finance's baseline, and fund the work as an investment against the measured loss.

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 "Your company has duplicate customer records spread across CRM, billing, support and...": https://scrivio-interview-library.netlify.app/databases/sql-coding-problems/cf21d9c8ad/