I want to store url's as unique in a mysql database table but with string type varchar and text the length of a 1000 is too long. Lengths of Search engine friendly url's can be typically long,whats an acceptable length?
- 1Possibly of use: supermind.org/blog/740/average-length-of-a-url-part-2Wrikken– Wrikken2010-09-20 23:45:59 +00:00Commented Sep 20, 2010 at 23:45
- 1If you are using VARCHAR, I'm not sure why you think 1000 is too long. VARCHAR only uses the space it needs for a given entry.Andrew– Andrew2010-09-20 23:46:32 +00:00Commented Sep 20, 2010 at 23:46
- when i declare the varchar as UNIQUE it needs a length to go with it so i would prefer to call it with no length so it can use the maximum of 65000(i think) if possible just to be coveredBaadier Sydow– Baadier Sydow2010-09-20 23:56:44 +00:00Commented Sep 20, 2010 at 23:56
Add a comment |
1 Answer
There really is no length that will guarantee unique- if you want to make sure a string of a given length is unique, you need to take a hash of the string and compare it, MD5 and SHA1 are common algoritms people use.
3 Comments
Adam Robinson
Which is obviously still not an absolute guarantee of uniqueness.
automagic
Not sure what you mean, an MD5 hash of a string is unique for all practical purposes
RD Ward
Still not guaranteed to be unique, which is a requirement of a URL.