views:

121

answers:

5

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

+1  A: 

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.

astander
USER table, contains the user's credentials that the user can use to login to his account control panel ie Username, password, registration date, security questions, etcUSER_PROFILE table, contains information about the user, such as Address, Phone Number, country of birth, country of citizenship etc
K001
Then i would place the Firstname/Lastname in the USERPROFILE table.
astander
A: 

What other data is stored in the USER table?

What distinguishes the data in USER_PROFILE and USER?

Once you've answered that, hopefully the user's name fits into one of these two distinctions fairly clearly.

Either way though, don't duplicate it.

Michael Shimmins
USER table, contains the user's credentials that the user can use to login to his account control panel ie Username, password, registration date, security questions, etcUSER_PROFILE table, contains information about the user, such as Address, Phone Number, country of birth, country of citizenship etc
K001
Then I'd put firstname, surname in user_profile.
Michael Shimmins
+3  A: 

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.

Duncan
A: 

Do not duplicate the date. Place them in the table in which they are grouped with the other fields they are most often used.

For example, if the first name and last name fields are private fields, required, and used with the fields in the user table more often than the profile table... put them in the USER table.

If they are required but most often used with phone number, address, etc, put them in the profile table.

If they are optional, without a doubt put them in the profile table.

xkingpin
A: 

If every entry in USER has exactly one entry in USER_PROFILE and vice versa, then logically (ie from a normalisation perspective) they should be a single table (potentially with different views over them, eg so that only authorised people see addresses and phone numbers).

You may have a situation where a user profile maps to multiple users (eg an individual has a normal and an 'administrator' account). In that case, firstname, lastname would be part of the profile.

Also, if a user has multiple profiles (eg a generic administrator account) that would also fit having firstname, lastname as part of the profile.

Gary
"Also, if a user has multiple profiles (eg a generic administrator account) that would also fit having firstname, lastname as part of the profile." in this case, wouldn't it be better to leave the firstname/lastname in the USER table, because 1 person can have multiple profiles, in which case his real first name/last name would also be the same?
K001