513

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?

vvvvv
32.9k19 gold badges70 silver badges103 bronze badges
asked Aug 21, 2008 at 19:50
5
  • 4
    Just make sure you allow non-alpha characters in the names! points at hyphen in his last name Commented Aug 21, 2008 at 20:03
  • 3
    See "Maximum length of a valid email id" for maximum e-mail address length. Commented Apr 16, 2011 at 17:50
  • 5
    One note: don't require both a "first name" and a "last name". Some people, like me, only have one name. (Proof: web.archive.org/web/20130115074449/http://saizai.com/…) Commented Jul 8, 2011 at 2:06
  • What about URL, like blog or link to profile? Commented Jan 14, 2015 at 6:53
  • 1
    Screwed if the name is as long as this one gintama.wikia.com/wiki/Jugem_Jugem Commented Apr 10, 2017 at 16:16

13 Answers 13

428

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.

    NOTE FROM COMMENTS: The maximum length of an email address is 254 characters (technically it's 320 chars, but certain key email-using protocols have a 254 char limit, so that's the practical limit). Site owners may still wish to use a shorter limit, to discourage non-human emails (as noted above, personal email addresses are shorter; see this related question).

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

    ADDITIONAL NOTE: Major US package delivery services only allow between 30 characters (UPS) and 46 characters (USPS) for their two street address fields (lines 1/2). While a cautious site might allow up to 50 characters, 35 characters (or 70, if there's only a single "Street Address" field) should be plenty even for most international sites (see page #9 of this UK government document and this Stack Exchange post)

  • City max length was 35.

    NOTE FROM COMMENTS: The longest city name is 85 characters (unless you count an alias of Bangkok).

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

machineghost
36k33 gold badges175 silver badges273 bronze badges
answered Aug 21, 2008 at 19:58
Sign up to request clarification or add additional context in comments.

15 Comments

Compared to yours, the databases I have access to are tiny, but even there I found an email address of 138 characters. The localpart component is obviously some sort of LDAP (or AD?) distinguished name.
The average lengths of email addresses in your database is not a good measure for recommendation. The maximum valid length of an email address is 254 chars and should be the length specified in the database. Additionally having lists of email addresses in a single column signifies to me that your data is not normalized and thus invalidates your answer further.
@Mario, if you think about it though, most software that uses emails for logins, for example, probably shouldn't allow ridiculously impractical email addresses. See discussion here stackoverflow.com/questions/1297272
Longest city name is 'Taumatawhakatangi­hangakoauauotamatea­turipukakapikimaunga­horonukupokaiwhen­uakitanatahu' coming in at 85 characters. en.wikipedia.org/wiki/List_of_long_place_names
@binarysubstrate Actually, the longest city name is Krung Thep Mahanakhon Amon Rattanakosin Mahinthara Yuthaya Mahadilok Phop Noppharat Ratchathani Burirom Udomratchaniwet Mahasathan Amon Piman Awatan Sathit Sakkathattiya Witsanukam Prasit (AKA "Bangkok") clocking in at a length of 187 characters.
|
196

UK Government Data Standards Catalogue details the UK standards for this kind of thing. It suggests 35 characters for each of Given Name and Family Name, or 70 characters for a single field to hold the Full Name, and 255 characters for an email address. Amongst other things..

flu
14.8k8 gold badges78 silver badges73 bronze badges
answered Aug 27, 2008 at 20:01

7 Comments

The link needs to be updated as of Oct 22, 2010. I googled for: site:*.gov.uk Name "35 characters" and found this doc justice.gov.uk/guidance/docs/electoral-reg-standards.pdf
Just a thought... shouldn't it be 71 characters for the first and last name in a single field, given that there needs to be a space?
Well, clearly they anticipate the occasional long forename (up to 35 characters) and the occasional long surname (up to 35 characters), but do not necessarily expect an individual with a combination of both lengthy forename and surname. That would just be greedy ;-)
If Mr El Tahir El Fadil El Siddig Abderrahman Mohammed Ahmed Abdel Karim El Mahdi actually uses all his names when filling in online forms I would be impressed. I have two middle names but I only ever use one of them apart from on official (i.e. government) forms.
@ian-nelson Email length according to RFC 3696: That limit is a maximum of 64 characters (octets) in the "local part" (before the "@") and a maximum of 255 characters (octets) in the domain part (after the "@") for a total length of 320 characters. Systems that handle email should be prepared to process addresses which are that long, even though they are rarely encountered.
|
92

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.

answered Sep 15, 2018 at 17:59

3 Comments

It’s been 10 years since I asked that question. With another 10 years of experience under my belt, I’m inclined to agree with you.
How exactly would you print a name that is 255 characters long on an envelope?
@BeKindToNewUsers Decrease the font size.
76

Some almost-certainly correct column lengths

 Min Max
Hostname 1 255
Domain Name 4 253
Email Address 7 254
Email Address [1] 3 254
Telephone Number 10 15 
Telephone Number [2] 3 26 
HTTP(S) URL w domain name 11 2083 
URL [3] 6 2083 
Postal Code [4] 2 11
IP Address (incl ipv6) 7 45
Longitude numeric 9,6
Latitude numeric 8,6
Money[5] numeric 19,4
[1] Allow local domains or TLD-only domains
[2] Allow short numbers like 911 and extensions like 16045551212x12345
[3] Allow local domains, tv:// scheme
[4] http://en.wikipedia.org/wiki/List_of_postal_codes. Use max 12 if storing dash or space
[5] http://stackoverflow.com/questions/224462/storing-money-in-a-decimal-column-what-precision-and-scale

A long rant on personal names

A personal name is either a Polynym (a name with multiple sortable components), a Mononym (a name with only one component), or a Pictonym (a name represented by a picture - this exists due to people like Prince).

A person can have multiple names, playing roles, such as LEGAL, MARITAL, MAIDEN, PREFERRED, SOBRIQUET, PSEUDONYM, etc. You might have business rules, such as "a person can only have one legal name at a time, but multiple pseudonyms at a time".

Some examples:

names: [
 {
 type:"POLYNYM",
 role:"LEGAL",
 given:"George",
 middle:"Herman",
 moniker:"Babe",
 surname:"Ruth",
 generation:"JUNIOR"
 },
 {
 type:"MONONYM",
 role:"SOBRIQUET",
 mononym:"The Bambino" /* mononyms can be more than one word, but only one component */
 },
 {
 type:"MONONYM",
 role:"SOBRIQUET",
 mononym:"The Sultan of Swat"
 }
]

or

names: [
 {
 type:"POLYNYM",
 role:"PREFERRED",
 given:"Malcolm",
 surname:"X"
 },
 {
 type:"POLYNYM",
 role:"BIRTH",
 given:"Malcolm",
 surname:"Little"
 },
 {
 type:"POLYNYM",
 role:"LEGAL",
 given:"Malik",
 surname:"El-Shabazz"
 }
]

or

names:[
 {
 type:"POLYNYM",
 role:"LEGAL",
 given:"Prince",
 middle:"Rogers",
 surname:"Nelson"
 },
 {
 type:"MONONYM",
 role:"SOBRIQUET",
 mononym:"Prince"
 },
 {
 type:"PICTONYM",
 role:"LEGAL",
 url:"http://upload.wikimedia.org/wikipedia/en/thumb/a/af/Prince_logo.svg/130px-Prince_logo.svg.png"
 }
]

or

names:[
 {
 type:"POLYNYM",
 role:"LEGAL",
 given:"Juan Pablo",
 surname:"Fernández de Calderón",
 secondarySurname:"García-Iglesias" /* hispanic people often have two surnames. it can be impolite to use the wrong one. Portuguese and Spaniards differ as to which surname is important */
 }
]

Given names, middle names, surnames can be multiple words such as "Billy Bob" Thornton, or Ralph "Vaughn Williams".

answered Nov 7, 2013 at 19:55

5 Comments

This is very informative but not a super useful answer. The next time I need a "probably correct" answer I'll let you know.
I know this is an old answer and it might've been personal taste in the end, but can you speak to why you chose to cap Postal Codes at 11 when the longest postal codes in the world (U.S. & Iran) are 10 characters? I'm coming up with my own schemas for school assignments and I can't come up with a good argument to exceed 10 characters beyond maybe future-proofing.
@DavidMetcalfe I see Ghana with 12 chars, incl dash
@NeilMcGuigan So where does your case for 11 come in if Ghana exceeds it at 12? Are you always storing these codes without hyphens?
@DavidMetcalfe see "Use max 12 if storing dash or space"
18

I would say to err on the high side. Since you'll probably be using varchar, any extra space you allow won't actually use up any extra space unless somebody needs it. I would say for names (first or last), go at least 50 chars, and for email address, make it at least 128. There are some really long email addresses out there.

Another thing I like to do is go to Lipsum.com and ask it to generate some text. That way you can get a good idea of just what 100 bytes looks like.

Patrick McElhaney
59.6k41 gold badges138 silver badges170 bronze badges
answered Aug 21, 2008 at 20:11

3 Comments

Oh my - the first person to note that larger fields don't necessarily mean more storage space, hence the "var" in varchar. NVarchar would usually make more sense for names though.
Depends on the implementation. You don't need NVARCHAR if VARCHAR supports UTF-8.
[N]Varchar sizes do however, affect your indexes.
10

I pretty much always use a power of 2 unless there is a good reason not to, such as a customer facing interface where some other number has special meaning to the customer.

If you stick to powers of 2 it keeps you within a limited set of common sizes, which itself is a good thing, and it makes it easier to guess the size of unknown objects you may encounter. I see a fair number of other people doing this, and there is something aesthetically pleasing about it. It generally gives me a good feeling when I see this, it means the designer was thinking like an engineer or mathematician. Though I'd probably be concerned if only prime numbers were used. :)

BenMorel
37.1k53 gold badges208 silver badges339 bronze badges
answered Aug 21, 2008 at 20:20

1 Comment

It is arguable that 2n - 1, 2n - 2 or even 2n - 4, two would be a better engineering decision because often strings are represented as zero-indexed character arays and terminated with a null char, byte or two bytes (UTF-8). Also with some databases going above 255 on a varchar requires an additional byte for storage (see stackoverflow.com/questions/2340639/…).
8

These might be useful to someone;

youtube max channel length = 20
facebook max name length = 50
twitter max handle length = 15
email max length = 255 

http://www.interoadvisory.com/2015/08/6-areas-inside-of-linkedin-with-character-limits/

answered Dec 29, 2016 at 6:51

Comments

4

I wanted to find the same and the UK Government Data Standards mentioned in the accepted answer sounded ideal. However none of these seemed to exist any more - after an extended search I found it in an archive here: http://webarchive.nationalarchives.gov.uk/+/http://www.cabinetoffice.gov.uk/govtalk/schemasstandards/e-gif/datastandards.aspx. Need to download the zip, extract it and then open default.htm in the html folder.

answered Jun 21, 2012 at 8:26

Comments

3
+------------+---------------+---------------------------------+
| Field | Length (Char) | Description |
+------------+---------------+---------------------------------+
|firstname | 35 | |
|lastname | 35 | |
|email | 255 | |
|url | 60+ | According to server and browser |
|city | 45 | |
|address | 90 | |
+------------+---------------+---------------------------------+

Edit: Added some spacing

Nimantha
6,5426 gold badges32 silver badges78 bronze badges
answered Apr 11, 2012 at 9:30

2 Comments

Why not just use VARCHAR 255 for everything that is a string? VARCHAR does not use padding and terminates with an additional one or two bytes.
varchar could be a little bit slow.
1

Just looking though my email archives, there are a number of pretty long "first" names (of course what is meant by first is variable by culture). One example is Krishnamurthy - which is 13 letters long. A good guess might be 20 to 25 letters based on this. Email should be much longer since you might have [email protected]. Also, gmail and some other mail programs allow you to use [email protected] where "sometag" is anything you want to put there so that you can use it to sort incoming emails. I frequently run into web forms that don't allow me to put in my full email address without considering any tags. So, if you need a fixed email field maybe something like [email protected] in characters for a total of 90 characters (if I did my math right!).

answered Aug 21, 2008 at 19:54

1 Comment

A top level domain can be more than 3 characters. So only 3 characters for TLD is not a safe calculation in these modern times. So to be on the safe side: I'd suggest taking at least 32 characters for TLD in consideration (max is 63 characters I believe). In this case: I'd suggest using at least 128 characters for email fields, preferably over 160 characters.
0

I usually go with:

Firstname: 30 chars
Lastname: 30 chars
Email: 50 chars
Address: 200 chars

If I am concerned about long fields for the names, I might sometimes go with 50 for the name fields too, since storage space is rarely an issue these days.

answered Aug 21, 2008 at 19:58

1 Comment

50 for email? 254 is the maximum actually
0

If you need to consider localisation (for those of us outside the US!) and it's possible in your environment, I'd suggest:

Define data types for each component of the name - NOTE: some cultures have more than two names! Then have a type for the full name,

Then localisation becomes simple (as far as names are concerned).

The same applies to addresses, BTW - different formats!

answered Aug 27, 2008 at 15:59

Comments

-2

it is varchar right? So it then doesn't matter if you use 50 or 25, better be safe and use 50, that said I believe the longest I have seen is about 19 or so. Last names are longer

answered Aug 21, 2008 at 19:57

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.