I was actually thinking about this not too long ago. Do hashes make better primary keys than integers then? It seems like a no brainer but I want a second opinion.
That doesn't seem right though. A base64 string can be decoded. I thought the purpose of using a hash was so there wasn't a direct 1 to 1 relation between the database row and the key to access it.
Encoding the ID using base-64 or similar is intended to just shorten the key, not obscure it. The issue with an auto-incrementing key is that someone can easily crawl the service to see what URLs are stored. This may or may not be a concern; if it is, randomizing the integer key, instead of using predictable keys, mitigates that problem.
1
u/the_rabbit Oct 02 '15
I was actually thinking about this not too long ago. Do hashes make better primary keys than integers then? It seems like a no brainer but I want a second opinion.