I am working on a social networking website in which I have idea of creating groups, events and friend list. I want user privacy for his friends like as given below :
1. User can select friends who can view his personal info or who can't. 2. User can manage who can see his events and groups and who can't.
I have designed a table structure for the same that I am pasting below :
Should there be any other structure that will be efficient and can minimize database hits and don't make database intensive.
If you're going to design database tables, you might want to read about normalization: http://en.wikipedia.org/wiki/Database_normalization
Storing ids separated by commas makes it difficult to update those records and to prevent duplicates. I'd recommend your allow and deny columns be split into separate related tables. This will not make it any more database intensive as you'll still only need one query, it just means you might have to have a query with a join.
I'd recommend using two (or three) tables, separating users + groups, and permissions.
The users/groups table can contain information specific (and isolated) to the user/group (so #'s 1 and 2 for the user) and then you can add a field for "type" or "category" that says if it is a user or group. If the information you're storing for users and groups are different enough, you can just have separate tables for each.
The permissions table can contain any permissions, including #'s 4-9 on your list (I don't really know the context of 10/11.) The table can also be use to manage group membership. The following is an example of how you could structure the permissions table:
Some example entries:
//Same as listing 1338 in user 1337's Allow_Friends Field
1002, 'user', '1337', '1338', 'Allow_Friends', 'True'
//Lists 1337 as a member in group # 43
1003, 'group', '43', '1337', 'Member', 'True'
These are just some examples to help you get started. Let me know if this was helpful, or if you need me to clarify anything :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.