I’m building a private social network with Yii that will have “comments” all over the site – in Profiles, Events pages, Group Threads, etc. When a user makes a post, they will be able to select the visibility of that content as:
- Anyone
- Registered Users Only
- Friends Only
- Custom (specific list of friends)
I’m trying to figure out how to model this for speed. I’ve considered using MySQL for writing the setting into a binary “is_secure” field in the Comments table – if it is true, then go to a table with three columns: comment_id, user_id, and group_id. Groups (group_id) would be for groups of users – Registered Users, Friends. Custom would make one row for each user that is selected (user_id).
This table will get huge (perhaps several dozen rows for each comment), so I’m wondering if using NoSQL is worth considering here for retrieval only, or if there’s a better way to model this.
Thanks so much!
Similar question to database “flags”. Search for related SO questions.
Instead of an
IF true/falsewith theis_securefield, just add 1-bit fields forread_all(anyone),registered,friends,custom. Add another table which holds the custom list would havecomment_id(from the previous table) andfriend_id(multiple rows). That way, in a single query with aLEFT JOIN on custom_friends_list_for_commentsyou can determine whether or not to show the page to a user. Optionally, custom could be a comma separated list (char field) but size limits might be an issue. Assuming 3-letter friend ids with a comma, each 255 char field can have 64 friends.