How do you deal with certain UGC-specific friends and the number of UGC-related statistics?

Source: Internet
Author: User
In a multi-user system, when user a publishes UGC, one is visible to all friends, a set of certain friends (such as B, C) visible, some friends are not visible (such as E, f two people), then
A the total amount of UGC that is visible is 100, and the list is all UGC
b The total number of UGC visible is 90, and the list content is public UGC and B visible UGC for a.
e See the total number of UGC is 50, listing content is a public UGC and e-visible UGC.
The list you see is not the same.

So in Php+mysql, how do you deal with related logic, table design?

Reply content:

In a multi-user system, when user a publishes UGC, one is visible to all friends, a set of certain friends (such as B, C) visible, some friends are not visible (such as E, f two people), then
A the total amount of UGC that is visible is 100, and the list is all UGC
b The total number of UGC visible is 90, and the list content is public UGC and B visible UGC for a.
e See the total number of UGC is 50, listing content is a public UGC and e-visible UGC.
The list you see is not the same.

So in Php+mysql, how do you deal with related logic, table design?

Assume that the table post is a user-published content that has a field of type marked with a privacy value of

0 - 'public'(完全公开)1 - 'protected'(指定可见)

Creates a new table noBlock that records the relationships of the specified visible Post and visible users. Such as:

id postId userId

Assuming that the scene is B logged in, the reading order of the content he reads is:
1. Read privacy the data for all values 0 post .
2. Combine queries post and noBlock tables to read noBlock userId Bid the data in the table.

Probably write a mysql statement (for example, the main, need to test):

(select * from post where privacy = 0) union (select * from post left join noBlock on post.id = noBlock.postId where post.privacy = 1 and noBlock.userId = Bid)
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.