I would like to generate a short, unique ID without having to check for collisions.
I currently do something like this, but the ID I currently generate is random and checking for collisions in a loop is annoying and will get expensive if the number of records grows significantly.
Normally worrying about collisions isn't an issue, but the unique ID I want to generate is a short unique string 5-8 characters, alpha-numeric, like tinyurl does.
EDIT: I would like to start out with 5 characters and if I hit 60 million entries, then go to 6.. so on and so forth.
To this end, I was thinking I could use an auto_increment value that is hidden from the users, and present them instead with an MD5
or some other method to generate a unique string from that.
Generated strings should not appear to be linear, so simply converting the auto_incremented ID into base 36
[0-9A-Z] is a bit too simplistic, but a function something like that is where I'm going with this.
EDIT: Security is not an issue as this will not be used to secure information. It is simply a shortcut to a longer string. Thank you.
Thank you for your suggestions and sorry for the delay. Dentist..