I’m curious what the database structure (mysql) might be for something like Google+ circles, and how they keep track of user-defined circles. I’d like to implement something similar for an app, where users can choose to share content with certain other users.
Essentially, a user can place a friend into a group he has defined to filter the content that friend can see. As of now, I have a fairly simple implementation of a friends system – it is a standard normalized database which includes a users table and a friends table.
Can anyone shed light on how one might go about setting up a database structure for “groups” or circles? I thought about adding an extra field to the Friends table, which would be a foreign key to a groups table. However, I can see this becoming unwieldy very quickly, especially if users can define groups and place friends in any number of groups.
Is there perhaps a quick implementation of this, or one that doesn’t require the computing power of Google’s servers?
The best approach I can think of is the following:
users table
friends table (2 userids and maybe one field for “accepted” or “not yet”) – I recommend two way friendship
groups table (group_id, owner(or not), description)
group_participants table (group_id,user_id and maybe one field for “accepted” or “not yet”)
And when you want to assign something, you can have various options, including “group” or you can append the list of groups to the list of users with some sort of letter like:
Also, assigning content to a group can be managed in two ways:
1) To actually assign permission to a group_id (This makes the group of viewers editable after the content is assigned)
2) Just assign the permission to each user of the group on the fly (This makes the assignment endure kicking someone out of a group)
If you go by option 1, then you can make assigning permission by “hand picking” people work like a hidden custom group.
Just my 2c