views:

40

answers:

1

I am building a data model for a social networking site and lost of how to model Users and Accounts.

1) User signsup and creates an Account. So we assign the User a user Id like on most social websites we see which is same profile ID. Now is that the account ID too? OR is there a separate account ID also hidden? If user can have multiple profiles, then user ID is seperate from account ID which is separate from each profile ID?

2) We assume 1 user has only 1 account. But when a user is editing his account or let's say an admin edits a user's account, then the User is editing an account, so two separate IDs required to model this?

3) What is the life of a user and account object? If user closes his account, that means both the user and account object get killed?

4) And who holds the user profile details, user settings, privacy, friends, etc? The user object or Account object, and which object is superior?

5) There are system objects such as photo, video, etc which a user can create/admin, so are those owned by the user or the account object?

6) What exactly makes an object? Say we have status updates, comments, profile details. Are these 3 objects? Or all considered 1 type of object and just 3 categories?

A: 

I understand your point about user vs. profile, but user vs. account?

For most of my designs, that's the same thing. Most of your questions seem to stem from this confusion. Why would you need separate IDs? Why would you differentiate between the two. If you have a need to, then maybe so. For example, maybe you have a user account that spans several services. This user has separate account information on the different services, but the same login. In that case, you'd need to have two separate objects: login (in the authentication system), and account (in the actual application). But I don't think you are creating such a large system. No?

6) If all those cannot be represented in the same code, they will have to be separate objects or derived from a similar object. For example, in some portals I see the PM (private message) system looks like a private forum thread between two or more people. Having not looked at the source, I would imagine then that forum topics/threads are the same or a similar, perhaps derived from the same, object.

sims
User vs Account I felt because how to model an Employee editing a user's account detail? I modeled UserType as Admin, Employee, Test, Member, Visitor. Also, account can be Business account, Advertiser account, etc. Unless I make these features below the account and not at same level as account? Want to play it safe from start so no need to change model once live data is flowing in.
kei30
Unless those "Accounts" are for use in separate software that you are going to build, they are not really useful. You may want to have "Roles" instead that you can assign to a user. So user: 1 is Admin, Manager, etc. It's a one to many relationship. So you need a table that holds that. Tables: user, role, userrole. userrole being: userid, roleid.. Something like that. There's many ways to do it. You might want to read a book or something about DB design. I will help you plan and make a more future proof DB.
sims