Creating IDs for uniqueness and URL referentiality
Question
I need to create objects and make them available on the web. Similarly to stackoverflow, I have something like.
http://stackoverflow.com/users/78374
However, in my case the ID of the object I create must be unique, so I am thinking about a UUID, leading to a URL like
http://example.com/users/{8e931066-7d87-4f2b-a3b5-608c4c9a9083}
because later on I will have to merge different databases together, and I don't want to have merging issues.
Is this an accepted practice? What are the alternatives?
Solution
If it's just a question of merging databases, giving each db a unique identifier and then combining that with the auto-increment PK would give unique ids for every object you could use and not worry about merging issues.
OTHER TIPS
There is no problem in that. Hotmail does that.
If merging must be 100% seamless, then a UUID is probably your best bet. If you are looking to generate more human-friendly URL's, you may consider using a unique "Account Name" that the user can define. This would potentially create conflicts if merging databases, but they can be overcome.
I would agree that this is an acceptable practice because it keeps the user ID unique when using it over multiple databases and applications.
I use the same practice in my caching application block. The caching application block generates a GUID when an item is cached and the application uses that GUID to retrieve the item from the cache.