How-to: Database field sizes

Some popular best practices on length and data type for common database fields.

 Title          Max 35 chars or 70 bytes.
                (Mr,Mrs,Miss,Ms,Dr,Rev,Sir,Lady,Lord,Captain,Major,Professor,Dame,Colonel.)

 First Name     Max 35 chars (accept spaces) or 70 bytes.
 Last Name      Max 35 chars or 70 bytes.
 Display name   Max 70 chars or 140 bytes.
 NameSuffix     Max 35 chars or 70 bytes. (OBE, MBE, BSc etc)
 Gender         1 digit code: Unknown(0), Male(1), Female(2), Indeterminate:Male+Female(3),
                Male from Female(4), Female from Male(5), Not Applicable(9)
 Address
    Flat Number/Name  Max 35 chars or 70 bytes.
    Building Number   Max 35 chars or 70 bytes.
    Street            Max 35 chars or 70 bytes.
    Town              Max 35 chars or 70 bytes.
    State/County      Max 35 chars or 70 bytes. (Optional)
    Postcode/Zipcode  Min 6 chars Max 12 chars or 24 bytes (some countries use non numeric codes)

    Country           Max 70 chars (The current longest country short name in ISO 3166 is 53 characters.)

or
Address (International Address Standard) Max 90 characters, up to seven lines.
 
 Email          Min 7 Chars, Max 255 chars  A full validated email address.

 Phone Number   Max 15 chars (no spaces) ITU E.164

Field sizes should be large enough to accept any plausable input, but small enough to throw an error on obviously invalid data. Setting sensible maximum sizes improves data quality by minimising copy/paste errors, if First_Name accepts 2000 characters then sooner or later somebody will paste the entire contents of an HTML email into that field.

Gender: US passports did not include gender until 1972, be very sure that you really need to collect this data at all.

Byte sizes being double the number of characters, assumes a maximum of 2 bytes (16 bits) per character.

Splitting address into several fields will simplify the design of automated letters & mail merge.
Keeping address as one long string with carriage returns will best support the wide variety of international address formats.
If you validate Postcode, make sure the validation works for every country you will be dealing with.

Use unicode, other text encoding schemes will not prevent users from entering carets or umlauts, they just make displaying the text difficult.

The 'Display name' can default to a concatenation of Title+ First + Last name, display names are often used for unofficial 'known as' names , e.g. William Helkathhazzurim is known to everyone as Bill Helka.

Some applications, such as credit card processing require a distinct separate First and Last name. In less formal applications the display name may be the ony name displayed to the end user.

“I'd call it a new version of voodoo economics, but I’m afraid that would give witch doctors a bad name” ~ Geraldine A. Ferraro

Related commands

UK Data Type Standard(pdf) - e-Government Interoperability Framework (e-GIF)
BS7666 - The British standard for the representation of address information
IETF RFC 3696 - Checking email addresses
IETF RFC 2822 - Data standard for email addresses
ISO/IEC 5218 - Gender codes (additions are not limited to those in the standard)


 
Copyright © 1999-2025 windevcluster.com
Some rights reserved