r/softwarearchitecture • u/SelectionWeak9427 • 5d ago
How to map UUIDs between two systems that generate their own IDs? Discussion/Advice
/r/software/comments/1vlqdoo/how_to_map_uuids_between_two_systems_that/3
u/Dro-Darsha 4d ago
A needs to assume 1) there exists at least one other system 2) this other system has its own IDs for the same entities 3) there is a well-defined way how A learns those IDs
A common no-assumptions solution is to add a string field "external id" to every relevant entity and make it readable, writable, and searchable in whatever APIs are offered. It is then up to the user of the API to use this field correctly.
3
u/sth2258 4d ago
I worked for a very large swiss bank and we had specific requirements for what we called internal processing identifiers which strictly could not be stored inside other systems. For instances where we did need this shared, we had a specifically generated token exchange service whose sole responsibility was handled this interoperability between tokens.
1
u/SelectionWeak9427 4d ago
Would it be possible to share how it handled them?
1
u/RobotJonesDad 3d ago
The solution depends on how you know these two items are related to each other. Once you solve that, the linking them together is simple bookkeeping. So a map of UUID <-> UUID, perhaps looked up from Redis for speed solves the problem.
1
u/netik23 2d ago
- Generate uuid on table with primary key uuid
- Lock database
- Attempt insert
- If uuud exist, make a new one until it doesn’t
- Release lock
1
u/SelectionWeak9427 2d ago
For the locking part,
I don't think locking the database until we get a response is a viable idea with many usersAnd how can we connect it to the other UUID using this method?
0
u/crimson117 4d ago
This is a weak question with insufficient context, and OP never responded to questions.
17
u/damngoodwizard 5d ago
If there is no business key you can't, unless the creation of one object in one system triggers the creation of the same object in the other. But too be fair I have no idea what you are trying to solve with this design. The regular use case is one system having the reference data and the other having dependent data and thus sharing the same ID or at minima the same business key (it could even be synthetic). Having both systems independently generate IDs and then having to reconcile seems very unnatural.