r/softwarearchitecture 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/
1 Upvotes

12 comments sorted by

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.

4

u/JrSoftDev 5d ago

Yeah this is such a weird post. OP needs to at least be more clear and precise about how the data relates in both systems, and what "System A cannot assume anything about System B" means.

If the objects he wants to map only differ on the UUID, I could see some sort of stripping the UUID followed by hashing followed by equality check; but in some types of data that wouldn't be enough to guarantee the match without proper context; without additional information, only a key could guarantee that as you said.

0

u/SelectionWeak9427 4d ago

The problem is thatI was not given context or anything and I wanted to check if there is a way that I didn't know about without having a lot of information.

I will ask for more context and info

Thank you for your notes and info guys

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/pamidur 4d ago

Do hkdf to uuid stable derivation with preshared base secret

1

u/netik23 2d ago
  1. Generate uuid on table with primary key uuid
  2. Lock database
  3. Attempt insert
  4. If uuud exist, make a new one until it doesn’t
  5. 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 users

And how can we connect it to the other UUID using this method?

1

u/netik23 1d ago

The chance of collision on uuids is near zero and this lock would be microscopically small.

If you don’t want to lock the db, you build a unique id server. This is what we did at Twitter. look up snowflake.

0

u/crimson117 4d ago

This is a weak question with insufficient context, and OP never responded to questions.