Hi,
we are currently designing an API for our product. The API offers access to a graph consisting of relations between types, such as users, posts or the like.
Now, those objects are referenced by primary key id in our database, but since every object is in a different table, those ids collide without the information of the type of object (=table).
This might not seem to be a problem but it really is for us - the API design gets much more inconsistent with those ID collissions/type informations in the wrong place.
Now the idea of using UUIDs came up, and since we probably will move away from an SQL db to K/V store in the future, that might not be the worst idea, also UUIDs offer far better uniqueness and also would scale better. So implementing UUIDs in our API wouldn't be the worst thing ever from various perspectives.
However, for the transition period, we still need to access the objects by DB id, and the UUID should be generated from an id and allow to infer the id from the UUID vice versa.
Something like 550e8400-e29b-11d4-YYYY-XXXXXXXXXXXX came to mind, where X would be the primary key from the DB, and YYYY would be a code for the type of object.
Is there a "right" way to do this? Can i break anything with this approach? Saving additional UUID information in whole or part is not really an option.
Thanks for your insight, Philip