Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of standard lengths for database fields

I'm designing a database table and once again asking myself the same stupid question: How long should the firstname field be?

Does anyone have a list of reasonable lengths for the most common fields, such as first name, last name, and email address?

like image 672
Patrick McElhaney Avatar asked Aug 21 '08 19:08

Patrick McElhaney


People also ask

What are field lengths in database?

For number fields, the field size determines exactly how much disk space Access uses for each value of the field. For text fields, the field size determines the maximum amount of disk space that Access allows for each value of the field.

What is the default field length in databases?

For database fields, VARCHAR(255) is a safe default choice, unless you can actually come up with a good reason to use something else. For typical web applications, performance won't be a problem.

What should length of address field?

Field Limits People will run into the following character limits when they fill out an Address field: Street Address: 255 characters. Address Line 2: 150 characters. City: 255 characters.

What is the maximum character length for a field name?

Field Names can only be a max of 255 characters.


1 Answers

I just queried my database with millions of customers in the USA.

  • The maximum first name length was 46. I go with 50. (Of course, only 500 of those were over 25, and they were all cases where data imports resulted in extra junk winding up in that field.)

  • Last name was similar to first name.

  • Email addresses maxed out at 62 characters. Most of the longer ones were actually lists of email addresses separated by semicolons.

  • Street address maxes out at 95 characters. The long ones were all valid.

  • Max city length was 35.

This should be a decent statistical spread for people in the US. If you have localization to consider, the numbers could vary significantly.

like image 143
Eric Z Beard Avatar answered Sep 19 '22 04:09

Eric Z Beard