Quick revision
The short answer
I would separate technical ids, which belong to one database, from business identities that span systems, and give core entities such as customer one master source that issues a global identifier. Every other system records an explicit mapping from its own id to that global id instead of matching on names or emails, merges and splits are planned operations with an audit trail, and identity rules become part of data governance with named owners.
What to remember
In this answer, we separated technical ids from business identities, chose one master source per core entity that issues a global identifier, replaced attribute matching with explicit, audited mappings, planned merges and splits as reversible operations that never delete ids, and made identity part of data governance with named owners and measurable progress.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would separate technical ids, which belong to one database, from business identities that span systems, and give core entities such as customer one master source that issues a global identifier. Every other system records an explicit mapping from its own id to that global id instead of matching on names or emails, merges and splits are planned operations with an audit trail, and identity rules become part of data governance with named owners.
Why this question is asked
Duplicate customers, two records that turn out to be one person, or one record that turns out to be two companies, cost real money: invoices sent twice, credit limits split across records, marketing consent applied to the wrong person. These problems rarely come from a single bug. They come from years of each system deciding identity on its own. Interviewers ask this at the leadership level because fixing it needs technical design and organisational ownership at the same time. In this answer, we will separate the kinds of identity, design a master source and mappings, plan for merges and splits, and set up the governance that keeps it working.
1Two Kinds of Identity
A technical id is the primary key a database gives a row, such as customer.id = 81723 in the billing database. It is perfect inside that database and meaningless outside it: the CRM has its own customer table with its own id 5521 for the same person. A business identity answers a different question: which real-world customer is this, across all our systems?
Most identity problems come from mixing the two. A team uses the billing id as if it were global, or decides that two records are the same customer because the email matches, and both choices break: ids collide when systems merge, and emails change, are shared by families, or are typed wrongly. The first principle is therefore to name both kinds of identity explicitly and never use one for the job of the other.
2A Master Source and a Global Identifier
For each core business entity, customer, product, supplier, we choose one system as the master source, the system that decides whether a new customer exists and issues its global identifier. That id is opaque, often a UUID or a prefixed string like CUS-7F3K9, and never reused or changed. Other systems still have their own technical keys, but every customer row carries the global id.
The master does not have to own every attribute. Billing can own payment terms and the CRM can own the sales owner. What the master owns is the existence and identity of the customer, and the history of how that identity changed.
6 messages in order. Play them, or step through them one at a time.
Systems keep their own keys; the global id ties them together.
3Recording Mappings Instead of Matching
When a system receives a customer from elsewhere, it should not search its own table by name or email to decide whether it already has that customer. Matching on mutable attributes is exactly how duplicates and wrong merges happen. Instead, each system stores the global id, and where several external systems are involved, a mapping table records the links explicitly.
The primary key states a rule in the database: a source record belongs to exactly one global customer. Matching rules, such as same tax id and same postcode, are still useful, but only to suggest links for a person or a reviewed process to confirm. They never silently decide identity.
4Planning for Merges and Splits
Even with a master, duplicates will happen: two sales reps register the same company in the same hour. So merging is a planned operation, not a database script someone writes during an incident. A merge chooses a surviving global id, marks the other as merged into it rather than deleting it, moves the links, and publishes a CustomerMerged event so other systems can update their references. Old ids keep resolving to the survivor, so a two-year-old invoice that mentions the retired id still finds its customer.
Splits are the harder case: one record turns out to be two companies. The operation creates a new global id and moves selected links and history to it, which is why every link records who made it and when. Both operations write to an audit trail, so that when someone asks why an invoice went to the wrong address, we can show which merge caused it and undo it.
- Matching rule flags a pairsame tax id, different global ids
- Data steward reviewsYesMerge: survivor keeps idNoMark as not duplicates
- Retire the other idstatus merged_into, never deleted
- Move links and publish event
CustomerMerged(old, survivor) - Audit record keptwho, when, why, how to undo
5 steps in order. Play them, or step through them one at a time.
5Making Identity Part of Data Governance
Technology alone does not hold this together, because every new system is a chance to start matching on emails again. So identity rules become part of data governance: each core entity has a named business owner and a technical owner, the rules for creating, merging and splitting are written down, and new systems must integrate with the master before they go live. Data stewards, the people who review suspected duplicates, have tools and time for it.
I would also measure the problem so progress is visible: the number of suspected duplicates found per month, how long they take to resolve, and how many systems still lack global ids. In the first year I would expect the duplicate count to rise as matching finds old problems, then fall as new ones stop appearing. Being honest about that curve keeps leadership patient while the work pays off.
6Follow-up questions
How do you introduce a master into an existing landscape with millions of records?
In stages. First assign global ids to existing records in one system and run matching across the others to propose links, with stewards confirming the uncertain ones. Then make the master the only way to create new customers. Older systems keep working with their own ids and gain the global id as an extra column, so nothing has to be rewritten at once.
Should the global id be the primary key in every database?
Not necessarily. Each database can keep its own technical primary key, which is often more efficient, and store the global id as a unique column. What matters is that every exchange between systems uses the global id, never a local key.
What about privacy rules such as erasure requests?
Identity mappings make them easier. With an explicit link table, we know every system that holds data about a customer, so an erasure request can be sent to each one and confirmed, instead of searching for the person by name.
7Conclusion
In this answer, we separated technical ids from business identities, chose one master source per core entity that issues a global identifier, replaced attribute matching with explicit, audited mappings, planned merges and splits as reversible operations that never delete ids, and made identity part of data governance with named owners and measurable progress.
Open with
I would start by separating two kinds of identity. A technical id is a database's primary key and means nothing outside that database; a business identity says which real customer this is across all systems.
Then, if they want more
Many of our problems come from mixing them, or from deciding identity by matching names and emails, which change and collide. So for each core entity like customer I would choose one master source that decides whether a customer exists and issues an opaque global id that is never reused.
Other systems keep their own keys but store the global id, and where several systems are involved we record explicit links from each source record to a global id, with who made the link and when. Matching rules only suggest links for people to confirm; they never silently merge.
Duplicates will still happen, so merges and splits are planned operations: the survivor keeps its id, the other is marked merged rather than deleted, links move, an event tells other systems, and everything is audited so it can be undone.
Finally, identity rules become data governance: named business and technical owners, stewards with time to review duplicates, new systems integrating with the master before go-live, and metrics like open duplicates and resolution time to show progress.
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.
- Official documentation
- Spring Data JPA reference, Hibernate ORM documentation, Spring Framework reference, Transaction management
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 "Identity bugs (entity equality, duplicated records, merged customers) have caused...": https://scrivio-interview-library.netlify.app/databases/jpa-relationships/42e54178c1/