If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Table Design - One to One?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-23-06, 08:20
dylatron dylatron is offline
Registered User
 
Join Date: Oct 2006
Posts: 3
Smile Table Design - One to One?

Hi,

I have been pondering this one for a long time now and would really appreciate your expertise.

I have a table called user, it has an auto increment id column. It also contains columns for the username, password etc. AND columns for the users profile, about, interests etc.

Now I am not sure whether this profile data should go in the user table or if would be a problem splitting it into a profile table with a one to one relationship.

I would quite like to seperate the profile as I do see some logic. Right now I have a couple of other tables profile_comment, and profile_rating. A one (user) to many comments or ratings.

I am thinking about setting it up with a user table, and profile table, and have the relationship for comments and ratings pointing at the profile table.

Also, what about key names? For the comment or rating table, user_id could be named better probably? profile_id or profile_user_id. It is a bit odd with the one to one between user and profile.

Hopefully some sense can be made from this. Please check out the attachment. (Another area which has a similar problem is blogs. A user can have one blog, with multiple comments, a blog table? a blog_comment table. What would you name the keys?)

Thanks for your time
Attached Thumbnails
Table Design - One to One?-er_question.jpg  
Reply With Quote
  #2 (permalink)  
Old 10-23-06, 09:26
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
in your diagram, if each user can have only one profile, i would go with option 1

as far as the column names are concerned, name them whatever you like, whatever makes sense
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 10-23-06, 09:56
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
Avoid 1-1 relationships. They are vestiges of a time when data storage was less efficient and data space was more expensive. These days, there is seldom a need for 1-1 relationships.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
  #4 (permalink)  
Old 10-24-06, 04:36
dylatron dylatron is offline
Registered User
 
Join Date: Oct 2006
Posts: 3
Thanks for the prompt replies.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On