173

I have a simple webform that will allow unauthenticated users to input their information, including name. I gave the name field a limit of 50 characters to coincide with my database table where the field is varchar(50), but then I started to wonder.

Is it more appropriate to use something like the Text column type or should I limit the length of the name to something reasonable?

I'm using SQL Server 2005, in case that matters in your response.

EDIT: I did not see this broader question regarding similar issues.

4
  • 1
    Check this related question for lots of discussion on the subject. Commented Aug 27, 2008 at 15:43
  • 2
    Something to note, in this age of globalization varchar is NOT usually the right datatype, chances are you should be using nvarchar.
    – Tao
    Commented Jul 16, 2010 at 7:45
  • @Tao: Since he's using MS SQL Server, I agree. But VARCHAR is the right datatype in other SQL implementations that have better support for UTF-8.
    – dan04
    Commented Dec 22, 2010 at 7:13
  • It should be mentioned, usually, those with long names have a shortened version of their name. What this means is, if you go for the 70 (35 split) character limit. Then don't feel bad when someone with 71 characters in their name comes along because they probably have a shortened version of it that's well under 70/35.
    – Tigerrrrr
    Commented Nov 28, 2023 at 9:31

12 Answers 12

171

UK Government Data Standards Catalogue suggests 35 characters for each of Given Name and Family Name, or 70 characters for a single field to hold the Full Name.

7
  • 3
    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
    – Tony R
    Commented Oct 22, 2010 at 20:01
  • Their links seem to be really bad... as of 8/2012: webarchive.nationalarchives.gov.uk/+/http://…
    – Thomas B
    Commented Aug 11, 2012 at 23:24
  • 7
    The longuest "reasonable" full name I've found is "Gisele Marie-Louise Marguerite LaFleche" (39-bytes-length). Commented Nov 3, 2012 at 20:51
  • A bit larger 54 chars : gw.geneanet.org/…
    – mestachs
    Commented May 13, 2015 at 5:55
  • 3
    New Zealand limits full names: they must be less than 100 characters long, including spaces, and cannot contain symbols or numbers. I guess hyphens are allowed in family names, though.
    – Glutnix
    Commented May 26, 2015 at 23:19
32

I know I'm late on this one, but I'll add this comment anyway, as others may well come here in the future with similar questions.

Beware of tweaking column sizes dependent on locale. For a start, it sets you up for a maintenance nightmare, leaving aside the fact that people migrate, and take their names with them.

For example, Spanish people with those extra surnames can move to and live in an English-speaking country, and can reasonably expect their full name to be used. Russians have patronymics in addition to their surnames, some African names can be considerably longer than most European names.

Go with making each column as wide as you can reasonably do, taking into account the potential row count. I use 40 characters each for first name, other given names and surname and have never found any problems.

2
  • Thanks for the answer, even if it has been a while. Commented Feb 19, 2009 at 0:58
  • Yeah, but how to reason? That's the point. You are simply saying that the length could be any.
    – Dmitry
    Commented Mar 24, 2022 at 9:36
10

I usually go with varchar(255) (255 being the maximum length of a varchar type in MySQL).

3
  • 43
    And do you also reserve 255 characters of space in your GUIs and other media where the first/last name gets displayed? ;-) Commented Nov 12, 2014 at 13:22
  • 6
    I used to think: "Why not always use varchar(255)?" Now I realize length constraints are mostly for the UI, and the constraints that designers can depend on when designing their UI, then it is about using up too much space in the database.
    – jdg
    Commented Oct 6, 2018 at 19:25
  • varchar(255) means max 255 bytes (not characters) Commented Jan 26, 2023 at 16:15
8

If it's full name in one field, I usually go with 128 - 64/64 for first and last in separate fields - you just never know.

1
  • I would say 64 characters is enough for the full name. Commented Mar 22, 2021 at 8:53
8

In the UK, there are a few government standards which deal successfully with the bulk of the UK population -- the Passport Office, the Driver & Vehicle Licensing Agency, the Deed Poll office, and the NHS. They use different standards, obviously.

Changing your name by Deed Poll allows 300 characters;

There is no legal limit on the length of your name, but we impose a limit of 300 characters (including spaces) for your full name.

The NHS uses 70 characters for patient names

PATIENT NAME
Format/length: max an70

The Passport Office allows 30+30 first/last and Driving Licenses (DVLA) is 30 total.

Note that other organisations will have their own restrictions about what they will show on the documents they produce — for HM Passport Office the limit is 30 characters each for your forename and your surname, and for the DVLA the limit is 30 characters in total for your full name.

2
  • 1
    just a note: "deedpolloffice[.]com" is not a government department, it's an entirely random private company which has the temerity to charge you for producing a PDF which you can type up yourself.
    – ash
    Commented Jan 13, 2023 at 11:37
  • As a fellow UKanian, this is very useful to me. Thank you!
    – Tigerrrrr
    Commented Nov 28, 2023 at 9:26
6

@Ian Nelson: I'm wondering if others see the problem there.

Let's say you have split fields. That's 70 characters total, 35 for first name and 35 for last name. However, if you have one field, you neglect the space that separates first and last names, short changing you by 1 character. Sure, it's "only" one character, but that could make the difference between someone entering their full name and someone not. Therefore, I would change that suggestion to "35 characters for each of Given Name and Family Name, or 71 characters for a single field to hold the Full Name".

3
  • 2
    The point of following that document is so that you're interoperable with other UK government systems, so you can't individually bump up the 70 to 71 and call it a day, otherwise systems with a 70 char limit will cut off your text. (You're not supposed to store the data in both forms within your own system.) It actually gets worse, since Full Name includes not just Family/Given, but also Title and Suffix, which also have a 35 char limit each, for a fun-filled 143 maximum characters in the appended fields. Sucks to be the developer who has to exchange data with both forms of name storage.
    – mmitchell
    Commented May 7, 2013 at 23:46
  • 3
    Clearly the guidance is written from the expectation that an individual may have a lengthy Given Name (up to 35 characters) or a lengthy Family Name (up to 35 characters), but are unlikely to have BOTH parts of the name be so lengthy.
    – Ian Nelson
    Commented Dec 10, 2013 at 15:34
  • From my PoV, you should never save the "full name" in the database, just save the first and last name separately and join them when needed. Commented Jan 1, 2022 at 18:12
3

What you're really asking is a related, but substantially different question: how often do I want to truncate names in order to fit them in the database? The answer depends both on the frequency of different lengths of names as well as the maximum lengths chosen. This concern is balanced by the concerns about resources used by the database. Considering how little overhead difference there is between different max lengths for a varchar field I'd generally err on the side of never being forced to truncate a name and make the field as large as I dared.

3

The answer may differ for a database field which is used to store the name, and for a field in a HTML form.

The length of the Name filed in a HTML can be guided by UX.

There is a study which shows that in Europe, cite: "The median was 6.5 characters for the first names and 7.1 characters for the last names". If you look at the charts below you'll see that 10 characters for each, given name and family name, is enough to have optimal UX.

enter image description here

Also should be noted that governmental databases can't shorten names for obvious reasons. You probably can. They can afford extra storage. You probably not.

2

Note that many cultures have 'second surnames' often called family names. For example, if you are dealing with Spanish people, they will appreciate having a family name separated from their 'surname'.

Best bet is to define a data type for the name components, use those for a data type for the surname and tweak depending on locale.

1
  • There's no advantage to making the limits smaller in locales that statistically have smaller values - the size of the field does not affect the space taken, unless some values actually take up those extra allowed characters (and then that means you made the right choice anyway)!
    – Tao
    Commented Jul 16, 2010 at 7:42
1

We use 50.

0
0

The average first name is about 6 letters. That leaves 43 for a last name. :) Seems like you could probably shorten it if you like.

The main question is how many rows do you think you will have? I don't think varchar(50) is going to kill you until you get several million rows.

2
  • 9
    If you have 50 million values between 10 and 15 characters in a varchar(20) column, and the same 50 million values in a varchar(50) column, they will take up exactly the same space. That's the whole point of varchar, as opposed to char.
    – Tao
    Commented Jul 16, 2010 at 7:43
  • @Tao see stackoverflow.com/questions/11132357/…
    – Mohammed H
    Commented Jun 21, 2012 at 6:02
0

depending on who is going to be using your database, for example African names will do with varchar(20) for last name and first name separated. however it is different from nation to nation but for the sake saving your database resources and memory, separate last name and first name fields and use varchar(30) think that will work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.