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

[eluser]wiredesignz[/eluser]
@Jedd, UUID digits are hexdecimal so I have no clue why you have "S" and "Y" in your examples.

It saddens me to see that people who have no understanding of a subject make such strong negative argument. It makes us all look silly.

Do some research yourselves or would you like to let me google that for you?
#12

[eluser]jedd[/eluser]
Quote:@Jedd, UUID digits are hexdecimal so I have no clue why you have ā€œSā€ and ā€œYā€ in your examples.
It saddens me to see that people who have no understanding of a subject make such strong negative argument. It makes us all look silly.
Do some research yourselves or would you like to let me google that for you?


I did a fair bit of research on these about four years ago, after some lengthy discussions with the aforementioned friend.

Didn't notice the S and Y in there - I just cut-and-pasted from the earlier examples. You're right, though. I should have taken far more care when examining those strings to make sure they were hexadecimal, but, you know how it is when you're in a hurry and the presence of an S or a Y isn't really germane to the point you're making, rather it's the relative length and complexity of the string.

But thanks for your constructive comments here, and I'm sorry there was nothing of actual substance in my message that you thought warranted a comment.

EDIT - Actually I should have also removed the dashes from the strings (as they are also not hexadecimal characters) but since they were cited in the original post, I assumed they were, also, some valid variation of the same basic thing. I'm surprised you didn't pick up on this stunningly important detail.
EDIT #2 - Oh heck. I just noticed that I also left an R in my cut-n-paste from the OP's message. I feel extra clueless now. I can only begin to imagine how sillier that makes everyone else look.
#13

[eluser]slowgary[/eluser]
Shame on you Jedd. Usually your posts are educated and well formed. I guess this will have to be the one that's not.
#14

[eluser]Thorpe Obazee[/eluser]
Here's a post regarding UUIDs too. Why UUID's
#15

[eluser]wiredesignz[/eluser]
Thanks bargainph, and RFC4122, the UUID specification can be found here.

http://www.ietf.org/rfc/rfc4122.txt

Actually very interesting to read.
#16

[eluser]sl3dg3hamm3r[/eluser]
Interesting post here. I often thought of using UUIDs as well, simply to have an additional security-layer for free. Well, layer might be a wrong, or at least too strong expression, but not beeing able to guess any IDs is quite a plus. But of course, this alone makes a web-app not secure per se.

By the way: WAFs (Web Application Firewalls) also make links unreadable by encrypting them, a similar effect.

One thing I didn't like from the above posted link though:

Quote:If you want to create polymorphic associates than UUIDs are going to make that a lot easier for you in CakePHP. Just create a table called 'comments' and give it a belongsTo of [Photo, Post, User]. But instead of creating a foreign key field for each model, you get away with just creating a single foreign_id field and setting that up as the foreign key for all the belongsTo associations. Since the UUID the foreign_id points to is unique across tables, you don't even have to track what model / table it actually belongs to. This avoids a more complex query and leads to improved performance for the setup. (You might still want to populate Comment.model just so you know where the link goes to without doing the actual lookup).

This might be convenient, but you can't keep up referential integrity that way, or do I miss something?
#17

[eluser]Dam1an[/eluser]
@bargainph, great link... I'm maybe even considering using them in my PMS, would make keeping tracking of what links to what a lot easier, as I can just point it at a UUID instead of ID and table name
Will have to weigh the pros and cons now (oh, that means I have to think)
#18

[eluser]wiredesignz[/eluser]
I feel guilty that my UUID generator is wasting ID's while I test it, because the ID's it generates will never ever be created again.
#19

[eluser]slowgary[/eluser]
But it's not really wasting them, because since past time will never occur again, you will never need to generate an ID based on that time. Technically, NOT constantly generating UUIDs is wasting them since every millisecond that passes sees a billion UUIDs that will never be given the chance to live - and some of those billions per second UUIDs would've even had a twin brother! ;-p
#20

[eluser]wiredesignz[/eluser]
No. It is actually wasting them. UUID's are unique they cannot be replicated.

No UUID I create can be created by anyone else ever again.




Theme © iAndrew 2016 - Forum software by © MyBB