Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is better practice when storing a users full name in the database? 1 or 2 columns?

Is it considered better practice to store a first_name and a last_name in 2 separate columns?

or would storing both in 1 column be ok?

like image 546
LondonGuy Avatar asked Sep 14 '11 14:09

LondonGuy


2 Answers

Only you know that, really. It depends if you're ever going to need to get those parts of the name back out separately.

Storing first name and last name in a single column isn't a reversible operation (in "Ellie May Jones", is "May" part of the last name or the first name?)

Also, what different cultures are you going to be dealing with? Not everyone in every culture even has two names -- see the Wikipedia article on Family names to understand the can of worms you may be opening up :)

Generally, I'm used to systems storing given and family name separately, and this gives you more potential to manipulate that data later, but then I deal primarily with a single, fairly small geographical region where people are used to being asked for a forename and surname. Also, the systems I run need to search for people based on their family name (easier if you can index a separate column) and send letters to people starting "Dear Miss Smith...")

You may also want to consider whether you need a "preferred" name -- my name is "Matthew", for example, but I much prefer being called "Matt". And there are plenty of people who prefer others to use one of their middle names when addressing them. Whether you need to capture a preferred name and a "real" name will depend on your requirements...

If I were you I'd start with two columns, assuming a fairly normal, English-speaking cultural bias. It's not a lot of code/storage overhead, and you can easily convert to a single column later if you find some pressing reason.

like image 142
Matt Gibson Avatar answered Sep 30 '22 13:09

Matt Gibson


Sure, just be sure you can deal with the german minister of defense, last thing you want is to cause a scene with the military because your code can't deal with his full name...

Karl Theodor Maria Nikolaus Johann Jacob Philipp Franz Joseph Sylvester Freiherr von und zu Guttenberg, and guess what? His "last name" is von und zu Guttenberg. He's not a one-off case either. De Luca is a family name, separated by a space.

I have a grandmother, and in Hungarian custom, a last name is actually your given name. Sztaki Helen is her proper full name, except her brother might be called Sztaki Fred, her father named Sztaki Greg. A similar thing exists for my Chinese friend Dai Wai, where Dai is also his family name.

As it turns out, names are damn confusing. Instead of researching and planning for all of these various rules just to figure out what someone's called, especially when you base it off of "first name" and "last name" (Don't call my grandmother Mrs. Helen, that's her given name not family name), step back and think about why you actually need to collect all this personal information about me.

I'd go on and totally blow your mind by explaining that not all cultures sort names alphabetically either, or that they even don't have a roman alphabet, but lets not go there just yet.

Do you actually need my personal information? Probably not. In some cases you will, in most... you don't. Don't ask for it.

If you really really do need it, ask for Sur Name and Given Name(s). Store it as two columns.

like image 41
Incognito Avatar answered Sep 30 '22 12:09

Incognito