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)