What VARCHAR sizes should be used for first and last names, phone numbers (preferably international), email adresses, urls, dictionary words and file names?
Edit: Zapped the introductory phrase to form a concrete question.
What VARCHAR sizes should be used for first and last names, phone numbers (preferably international), email adresses, urls, dictionary words and file names?
Edit: Zapped the introductory phrase to form a concrete question.
The rules of thumb I use are:
The answer depends on the database you are using. For Postgres, you may as well use TEXT for everything; no other type will be more efficient. For Oracle you can use VARCHAR2(4000) for all fields where 4000 characters is sufficient; again no other character type will be more efficient.
there are really two schools of thought for how to determine field size.
This makes it unlikely that it will ever be required to expand a field which can be very expensive to do, also with fields like varchar there is very little lost in terms of wasted space/performance.
This can help increase data integrity and also be very useful in special cases. For example if a field is commonly used in a report where space is an issue limiting it to X characters saves having to decide how to trim or truncate data. Limiting sizes can also be useful if you can guarantee a field will always have a specific length, this can help ensure your data has a minimum quality, for example storing state postal codes as a CHAR(2) ensures that longer entries won't happen, or storing numeric values as a numeric type ensures that what is stored is a number. It can be extremely hard to find numbers for field length for most fields though and the cost of having to change after implementing can be very expensive.
The best rule of thumb is do what makes your DBA happy.