Skip to content
Advertisement

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?

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement