Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UUID namespace and name. How to retrieve it?

I have the following problem. I assign to any object in my database a UUID. When I get a UUID from any source, to obtain the object I need to know what type of object is, so I can query the correct table in the database. As far as I understand, UUID version 5 supports namespacing, but I am not sure I clearly understand its meaning.

Is it possible to associate to a UUID information about the namespace it belongs, so to recover it later ?

like image 207
Stefano Borini Avatar asked Oct 21 '09 09:10

Stefano Borini


1 Answers

Is it possible to associate to a UUID information about the namespace it belongs,

Yes, see this document.

so to recover it later

Maybe. The problem is that two different namespaces may map to the same hash value. To avoid this, you should manually number your names (instead of hashing them). Then put the number into the octets 0-3. That gives you a deterministic mapping between UUIDs and names.

like image 118
Aaron Digulla Avatar answered Oct 07 '22 22:10

Aaron Digulla