In my application I have two tables: Users and Profiles. A user has a profile and profile belongs to a user. The reason I did this was because I wanted to keep the tables simple and the controllers smaller for each e.g. The UserController deals with logins, forgot passwords etc and ProfileController deals with edit, profile view etc.
Now when linking to other models e.g. Posts or Comments or Friends I have run into a dilema!
Currently I Posta and Comments to the User via a user_id foreign key and then pull in the Profile info using a contain in the query but for Friends I link via the Profile ID.
So what would be the better option? As it seems better to link through the Profile id as that is more relevant and in the future should a user have additional stuff .e.g Groups or Pages (think Facebook) then it would be hard to differentiate between what is linked to the Profile and what is linked to the Group or Page for the same user.
I know this is a slightly open question BUT it’s something that would help me if others could share there thoughts, especially with performance and code efficiency.
Linking the friends using the profile ID makes no sense to me (since friends is a recursive relation on the users table).