Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You probably don't want integer primary keys, and you probably don't want UUID primary keys. You probably want something in-between, depending on your use case. UUID is one extreme on this spectrum, which tries to solve all of the problems, including ones you might not have.




What's in-between? I posted the article because I'm in the middle of that choice and wanted to generate discussion/contradiction.

So far, people have talked a lot about UUIDs, so I'm genuinely curious about what's in-between.


An example would be YouTube's video IDs. It's custom-fit for a purpose (security: no, avoiding the problem where people fish for auspicious YouTube video numbers or something: yes).

Another example would be a function that sorts the numbers 0 through 999 in a seemingly random order (but's actually deterministic), and then repeat that for each block of 1000 with a slight shift. Discourages casual numeric iteration but isn't as complex or cryptographically secure as UUID.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: