views:

41

answers:

1

Hello,

I have a best practice/efficiency/performance issue.

If I want to have a profile page for each user in my system and i already have a user model. Is it better to have all the users information in the user model and pull it on the show page of users

so users/show will access the user model and grab all the relevant data like about me, interests, etc.

OR

should I do something like create a profile model and do has_one :profile, in the user model and keep the relevant profile data in there?

This isn't a how to question but rather, what is known to be "best practice" and why use one method over another? Thanks!

+4  A: 

If it were my app, I would be asking the question: "how often is the users table going to be queried for without the profile." If the answer is often, then sure, normalize away. But know that creating another table for the profile adds the overhead of a join and an extra foreign key (maybe even an index...).

I've seen it done both ways, and to me it's more natural to keep the user's information with the user. If the information gets really detailed like multiple contact addresses, etc., you might think about breaking some of the stuff out then.

Steve Ross
thanks Steve, I've seen it done both ways as well and I've always wondered. Your answer makes a lot of sense.
bob