Stefano Borini
Stefano Borini

Reputation: 143865

Creating IDs for uniqueness and URL referentiality

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?

Upvotes: 3

Views: 315

Answers (4)

Michael Kniskern
Michael Kniskern

Reputation: 25270

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.

Upvotes: 1

Karmic Coder
Karmic Coder

Reputation: 17949

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.

Upvotes: 1

code_burgar
code_burgar

Reputation: 12323

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.

Upvotes: 6

Shawn Mclean
Shawn Mclean

Reputation: 57469

There is no problem in that. Hotmail does that.

Upvotes: 1

Related Questions