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?
Asked
Active
Viewed 1,806 times
1
-
1Possibly of use: http://www.supermind.org/blog/740/average-length-of-a-url-part-2 – Wrikken Sep 20 '10 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 Sep 20 '10 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 covered – Baadier Sydow Sep 20 '10 at 23:56
1 Answers
1
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.

automagic
- 1,067
- 8
- 10
-
3Which is obviously still not an absolute guarantee of uniqueness. – Adam Robinson Sep 21 '10 at 00:08
-
Not sure what you mean, an MD5 hash of a string is unique for all practical purposes – automagic Sep 21 '10 at 16:15
-
1Still not guaranteed to be unique, which is a requirement of a URL. – Ryan Ward Valverde Jan 23 '12 at 17:52