Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL name and surname in 2 columns vs name in 1 column

One simple question and I couldn't find any answers to id :

Should name be in 2 different DB columns ( name / surname ) or in 1 column ( name + surname ) ?

In all the projects I had they were in 2 different columns, but now I have to start a new project and I was wantering how it better to store it. I mean, the 2 different columns gave me a bit of trouble and sometimes slowed performance down. Please note this very important thing :

  • A very important part of the public part of the site will be an advanced search and it WILL search for the full name in about 200k records.

So, what do you suggest ? 2 columns or 1 ? I am inclined twords the 1 column solution because I cannot find any advantages in using 2, but maybe I am wrong ?

EDIT

Thank you for the answers. The only reason for this question was for the performance issue, I need all the extra boost I can get.

like image 697
Cosmin Avatar asked Jan 25 '26 12:01

Cosmin


1 Answers

The point of a relational database is to relate data. If you store a full name (e.g. John Smith) in a single field, you lose the ability to easily separate out the first and last names.

If you store them in separate fields, you can VERY easily rejoin them into a single full name, but it's quite difficult to reliably pull a name apart into separate first + last name components.

like image 116
Marc B Avatar answered Jan 28 '26 02:01

Marc B



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!