Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"FirstName" and "LastName" store in database USER or USER_PROFILE table?

Currently I store the user's "FirstName" and "LastName" in the USER table, but i also have a USER PROFILE table (which provides additional information about the user) and it would makes sense to have the user's "FirstName" and "LastName" in the USER PROFILE table aswell.

So what do i do? make two copies of "FirstName" and "LastName"?


USER table, contains the user's credentials that the user use to login to his account control panel ie Username, password, registration date, security questions, etc

USER_PROFILE table, contains information about the user, such as Address, Phone Number, country of birth, country of citizenship etc

Relationship

USER 1.* USER_PROFILE

like image 545
001 Avatar asked Oct 15 '22 06:10

001


2 Answers

Put the first name and last name in with the user profile unless they are needed as part of the login procedure. That way there is less data to process, and they belong there more than with account information. Only leave them with login data if they are needed and it will speed up the querying.

As others have said, don't duplicate the data. You can just join the tables when you need it. You should have a primary key on your user table (preferably not the username, they can change) which is referenced from the user profile table. If you don't, add one now before you even think about doing anything else.

like image 141
Duncan Avatar answered Oct 31 '22 10:10

Duncan


No, dont make 2 copies. Either leave it in the USER table, or move it to the USERPROFILE table.

If you have a userid in both you can use a join.

If you can provide a little more structure detail between USER and USERPROFILE we can make a quess as to in which one this belongs. From what I can think, it would seem that the USERPROFILE is the users personal details, so this might seem like the logical place to put the mentioned information.

like image 22
Adriaan Stander Avatar answered Oct 31 '22 10:10

Adriaan Stander