Storing names in a database

I recently stared at creating a small social network, and I lost a little and confused the memory of names.

So, the fact is that this network will be open to 4 different countries, Hungary, Russia, France and America.

The bad part, if I wanted to store the names in first name , last name in the database, it would not be a good idea, because, for example, in Hungary the names are switched, for example, if Amirecian Citizen signs as Scott Summers, Scott is the first name , and Summers is last , but, for example, in Hungarian it’s completely different. The first name is the last name, and the last name is the first. So, if Scott is Hungarian, his name would be: Summers Scott.

My experience is in my country (in Hungary), where people really got upset when their name switched, when they subscribed, for example, to facebook, so I would like to avoid this.

I thought to give a full name field in the table, but this is not a good idea (in my opinion).

so I would like to ask for more experienced developers opinions, if possible, thanks

+4
source share
2 answers

If each area in which you work has an agreement that everyone has a family name, one or more given names and prefers these names to be formatted in a specific format and you need to process the individual parts of the name, then save these facts :

Family Name , Given Name , Other Names and Preferred Name Format . I also recommend that you give them a Preferred Name .

If you usually use the Preferred Name to address them, and you will use the Preferred Name Format to control the assembly of Family Name , Given Name and Other Names in a format acceptable to them in their culture.

The development of a user interface that allows them to enter them without errors remains as an exercise for the reader :-)

+4
source

You can create a view for a table containing names and save the flag in the table itself. You can get the full name from SQL. For instance:

 SELECT IF(nametable.last_name_first, CONCAT(nametable.last_name,' ',nametable.first_name), CONCAT(nametable.first_name,' ',nametable.last_name)) AS fullname FROM nametable; 
0
source

Source: https://habr.com/ru/post/1438574/


All Articles