views:

392

answers:

4

In regards to database design, what are the recommended column sizes for such fields as someones first, middle, and last name? Additionally, is the standard one character for a middle name safe, or should additional space be allowed for middle initials?

Specifically, I'm looking for sizes that will allow this be something I don't have to worry about for international usage. I have seen some middle initials that are two characters, so I doubt that a single character is a good idea, but I'm curious to see if there are any guidelines out there already.

+1  A: 

I am not sure about length but if you are going to be internationalizing then definitely go with nvarchar as this will support any "extended" ASCII characters you may encounter. The other good part about nvarchar is that it has a fixed max length but does not pad values out to that length.

In other words my name would be stored as

'Andrew'

in an nvarchar(20) field but would be stored as

'Andrew              '

in a char(20) field. So with this in mind I would shoot for a large number for names with the thought being that you will not be wasting that extra space using nvarchar.

Andrew Hare
This will save space, but it's more efficient to read/write to a table with fixed size records.
Dana the Sane
@Dana -- I'd want to be very sure that I need the efficiency before I'd take on the added complexity of having to trim the values that I retrieve. My personal feeling is you should use varying types for varying data and fixed types for fixed data. Y/N can be char(1), but names should be varying.
tvanfosson
You're comparing apples and oranges - the non-internationalised version of nvarchar(20) is varchar(20), which will not pad with space as both nchar(20) and char(20) will do.
Andrzej Doyle
+2  A: 

Personally I think it boils down to how much data you reasonably expect to have to store. Even if you're going to have a million names, it probably wouldn't hurt to use a char(64) or bigger for each name. If size is an issue, you can start with 32 and bump up the size with alter column, as necessary.

Dana the Sane
+1  A: 

You need 590 characters combined if you want to support the world's longest name.

Jeb
I expect this is one of the very few answers on SO that can link to www.museumofhoxes.com as a valid supporting link. :-)
Andrzej Doyle
When wikipedia fails you, go to the next tier... :)
Jeb
+3  A: 

ISO has not issued standards for naming of humans (yet), though I hear a preliminary draft is being passed around at the very highest levels.

:)

Seriously, 64 or so should be adequate for 99.99% of first and last names -- in any language. I've never seen anything other than one char for an MI (though you're right, many folks have more than one).

BTW: Unless I'm mistaken, email addresses -- technically -- can be up to 320 characters in length and can contain ! # $ % & ' * + - / = ? ^ _ ` { | } ~ and . provided that . is not the first nor last character, nor may it appear two or more times consecutively.

PS. My pet rabbit's name is "His Imperial Majesty Theopolops Bunny Galore". Needless to say this was truncated in the vet's database. I think they have it as "His Imperial Maj". So it goes.

Clayton