by EzGraphs · 13y ago · 0 comments
Yeah - they seem kind of silly and meaningless, so instead you use sequential integers. After all, they work nicely with object-relational frameworks like ActiveRecord, they are sequential, and they are more "human readable". And then one day you have a subset of data that you need to migrate from one environment. And when you try, you end up with some clashing records created in the target environment. No big deal, you will just increment all of your sequential integers so that there are no clashes. Oh wait, there are foreign keys - need to update those as well. Which reminds me, what is going to happen when ids in the target system catch up the the ones imported. OK we can change the sequence to cause it to start adding records after the one imported. Hey, this is really kind of complicated. There must be an easier way...
Hmmm... about those GUIDs? They completely eliminate an entire class of problems that occur when migrating data across environments (a very common scenario in some quarters).
If this type of scenario never will arise for you, then GUIDs may not make sense for your application. Hopefully this does explain why some "people just love" them.
Let's say I have database A with sequential IDs, and database B with sequential IDs. Couldn't I just translate the sequential IDs to GUIDs in both databases, merge them to database C and then translate the records from A and B to sequential IDs?
Or modyfying IDs is a big no-no in this scenario?
Seems they are mostly just like autoincrement integers with the random GUID data following. I guess you still have the storage constraints, but now you at least can order them easily.
http://instagram-engineering.tumblr.com/post/10853187575/sha...