Welcome Guest, Not a member yet? Register   Sign In
Why I use UUIDs for primary/foreign keys
#41

[eluser]Jondolar[/eluser]
Wouldn't the proper usage of a globally unique ID be when you actually need a globally unique id in your application? If your application is a blog, it probably was not specified or designed to allow all posts to be integrated with all other blogs on the planet. I would venture to say that there are times it makes sense to use a UUID (or GUID) but would be hard-pressed to believe that using a UUID for every pk makes sense. Data that is distributed makes sense (ads, feeds, others?). Data specific to your application and not designed to be distributed (transactions, products, comments) just doesn't seem like it would benefit having a UUID and there are many posts in this thread that point out the downfalls.

I read through all the posts but I don't remember seeing a specific description of how to actually retrieve the UUID that is generated by MySQL (or other database engine) when using the UUID() mysql function.
#42

[eluser]slowgary[/eluser]
I agree Jondolar. I think that about sums up the entire discussion - there are times when it makes sense, but UUIDs as Primary Keys is not for every situation.

I know you can't get the UUID as you can an integer, using mysql_insert_id(). I think you have to store it first in a variable with AS or something and then JOIN it to your query or something. I'm not really sure how it works, but I think one of the posts mentions how.




Theme © iAndrew 2016 - Forum software by © MyBB