There are the standard A-Z, a-z characters, but also there are hyphens, em dashes, quotes, etc.

Plus, there are all of the international characters, like umlauts, etc.

So, for an English-based system, what's the complete set? What about sets for other languages? What about UTF8, UTF16, etc?

Bonus question: How many name fields are needed, and what are their maximum lengths?

EDIT: There are definitely two different types of characters involved in people's names, those that are there as part of the context, and those that are there for structural reasons. I don't want to limit or interfere with the context characters, but I do need to deal with the structural ones.

For example, I had a name come in that was separated by an em dash, but it was hard to distinguish that from the minus character. To make the system easier for searching, I want to take all five different types of dashes, and map them onto one unique character (minus), that way the searcher doesn't need to know specifically which symbol was initially entered.

The problem exists for dashes, probably quotes as well, but also how many other symbols?



UTF-8 should be good enough, as far as name fields, you'll want at minimum a first name and last.

But I only have one name. What about me? :)
To be pernickerty; UTF-8 isn't a character set, it's a character encoding.
Rowland Shaw
+10  A: 

There's a pretty nice blog post on that topic (with a second part) that explains the problems (and possible solutions) pretty well.

Personally I'd say: support every printable Unicode-Character and to be safe provide just a single field "name" that contains the full, formatted name. This way you can store pretty much every form of name. You might need a more structured storage, but then don't expect to be able to store every single combination in a structured form, as there are simply too many different ones.

Joachim Sauer
It makes sense, but I'm surprised, I always thought that full-name and salutation were older cruder conventions than first, middle and last.
Paul W Homer
@Paul: Perhaps so, when you're only dealing with a single culture and language. But when you get into different name orders, different numbers of names, etc., it can be hard for a human to follow all the possibilities, never mind a program, so just let the user deal with how to render his own name.
Dave Sherohman
+5  A: 

Whitelisting characters that could appear in a person's name is the wrong way to go, if you ask me. Sure, [A-Za-z] is a fair starting point, but, as you said, you get problems with "European" names. So you map all the umlauts, circumflexes and those. What about Chinese names? Japanese? Indian? Hebrew? You're entering a battle against wind turbines.

If you absolutely must check the validity of someone's name, I'd suggest doing a modest blacklist of certain characters. Braces, mathematical characters, some punctuation and such might be safe to ignore. But I'd be cautious, if I were you.

It might be best to just accept whatever comes in. UTF-16 should be today's overkill character set, that should be adequate for some years to come.

Edit: As for your question about name length and amount of names. If you really want people to write their real and complete names, I guess the only foolproof answer to both of those questions would be "infinite". Not being able to whip out any real examples for human beings, but surely there are analogous examples for humans as the native name for the city of Bangkok.

Henrik Paul
I would allow anything but whitespace
But really, why? What if my surname was "von Rettig"? If I would index that surname, it would be written "Rettig, von". You can never be too sure...
Henrik Paul
I don't want to limit the input, but in certain cases I want to map several characters down onto a single one, for instance I want to map any long dashes in UTF8 onto minuses in ASCII, so searching is easier.
Paul W Homer
dashes to hyphens/minuses sound harmless enough to me. But were you thinking also of mapping Ä to A? In Nordic (in Northern Europe, that is) languages, those two characters are very different. In fact, A being the last character in the alphabet, Ä is the second to last in Finnish (and a few others).
Henrik Paul
I mean: "A being the _first_ character in the alphabet..."
Henrik Paul

Any character that can be represented by any multiple of eight bits (greater than zero) is a possible character for a person's name. Lengths of both names and encodings are arbitrary, so no upper bound should be considered.

Just make sure you sanitize your database inputs so little Bobby Drop-tables doesn't get ya.

I'd prohibit at least all unprintable Unicode characters (control characters), as they are very, very, very unlikely to be contained in a name.
Joachim Sauer
Yes, but he didn't restrict his inputs to Unicode, did he? I'm trying to demonstrate that it's futile to try and guess what will and will not be a part of a valid name. You either place arbitrary restrictions on a name, and offend a few people later on, or you place no restrictions and sanitize.

Depending on the complexity of your name structure I could see:

  1. First Name
  2. Middle Initial/Middle Name
  3. Last Name
  4. Suffix (Jr. Sr. II, III, IV, etc.)
  5. Prefix (Mr., Mrs., Ms., etc.)
That's just for american names.
This isn't really the question that was asked, but if you're trying to answer "How many fields are needed" then I would argue that the answer is one. How many fields are appropriate to your application's purpose is a whole other question.

What do you do when you have "The Artist Formerly Known as Prince". That symbol he used is not a character in the unicode set (AFAIK).

It's some levity, but at the same time, names are a rather broad concept that doesn't lend itself well to a structured format. In this case, something free-form might be most appropriate.

Edge case. Ignore. The world will survive 0.000005% of people having hard-to-digitize names.
@willc2: Not at all. What about names in Japanese, Chinese, Arabic, etc, etc, etc. Those are certainly not edge cases.
+2  A: 
AFAIK (and Wikipedia seems to agree with that) the symbol was never the legal name of Prince, but only the stage name ;-)
Joachim Sauer
The fact that the British government does it all wrong shouldn't keep anyone from doing it right.
I'm warped enough to name a child after Håkon Wium just to cause issues for said systems (that and in honour of his work with CSS)
Rowland Shaw
+5  A: 
Joachim Sauer
was just about to post this... +1
Ali A
hilarious i know my first kids name now
+1  A: 
Which is of course, nuts. The way to deal with Bobby Tables is not to reject his name, but to escape and quote it such that it's not interpreted as SQL.
No, the way to deal with Bobby Tables is to use SQL placeholders instead of interpolating the name into your query.
Dave Sherohman
+3  A: 

On the issue of name fields, the WRONG answer is first name, middle initial, last name, etc. for many reasons.

  1. Many people are known by their middle name, and formally use a first initial, middle name, last name format.

  2. In some cultures, the surname is the first name, and the given name is the last name.

  3. Multiple first and/or middle given names is getting more common. As @Dour High Arch points out, the other extreme is people with only one word in their name.

In an object-oriented database, you would store a Name object with methods to return a directory-style or signature-style name; and the backing store would contain whatever data was necessary to support those methods.

I haven't yet seen a relational database model that improves on the model of two variable-length strings for directory-style and signature-style names.

Ken Paul
There are people like Cher, Suharto, and Sukarno whose legal name is a single word.
Dour High Arch
Don't forget Teller,
Dave C
+1  A: 

It really depends on what the app is supposed to be used for.

Sure, in theory it's great if you allow every script on god's green earth to be used, but if the DB is also used by support staff, are they going to be able to handle names in Japanese, Hebrew and Thai script? Can you printer, if it's used to print postage labels?

You might add an extra field "Latin Transcription", but IMO it's really OK to restrict it to ISO-8859-1 characters - People who don't use Latin characters are by now so used to having to use a transcription that they don't mind it anymore, unless they're hardcore nationalists.

Michael Borgwardt