1

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?

3
  • 1
    Possibly of use: supermind.org/blog/740/average-length-of-a-url-part-2 Commented Sep 20, 2010 at 23:45
  • 1
    If 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. Commented 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 covered Commented Sep 20, 2010 at 23:56

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Which is obviously still not an absolute guarantee of uniqueness.
Not sure what you mean, an MD5 hash of a string is unique for all practical purposes
Still not guaranteed to be unique, which is a requirement of a URL.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.