databasestandards

List of standard lengths for database fields


I'm designing a database table and asking myself this 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?


Solution

  • W3C's recommendation:

    If designing a form or database that will accept names from people with a variety of backgrounds, you should ask yourself whether you really need to have separate fields for given name and family name.

    … Bear in mind that names in some cultures can be quite a lot longer than your own. … Avoid limiting the field size for names in your database. In particular, do not assume that a four-character Japanese name in UTF-8 will fit in four bytes – you are likely to actually need 12.

    https://www.w3.org/International/questions/qa-personal-names

    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. Don't prematurely optimize.