First case
Comment Nested reply, similar to this case, how is the database designed?
I have two ideas, one is to save the comment ID of the reply, so that the bad is that each nested comments to iterate over all the parent class, performance is not good. The second idea is to save the ID of all the parent classes, separated by a symbol (comma or dash), in a field.
The second case
Weibo forwarding, how is the database designed?
I also have two kinds of thinking, one is to store and forward the person's content ID, one is to keep the ID of all the people who forwarded the microblog, and the other to store and forward all the content. Which one is more appropriate?
Is there any more suitable way of thinking?? Please be very generous to point out.
Reply content:
First case
Comment Nested reply, similar to this case, how is the database designed?
I have two ideas, one is to save the comment ID of the reply, so that the bad is that each nested comments to iterate over all the parent class, performance is not good. The second idea is to save the ID of all the parent classes, separated by a symbol (comma or dash), in a field.
The second case
Weibo forwarding, how is the database designed?
I also have two kinds of thinking, one is to store and forward the person's content ID, one is to keep the ID of all the people who forwarded the microblog, and the other to store and forward all the content. Which one is more appropriate?
Is there any more suitable way of thinking?? Please be very generous to point out.
Building for Comments
First, now this form is rare, functionally simplified, not applicable to the trend of mobile products.
On the implementation, we used to record the number of comments he replied to in each piece of data. Look at your problem, personal feeling, your second implementation of the use of redundant storage, record all the superior comment number, is a good note, better performance. When storing multiple values, I used to like to separate them with commas, and now I like to store them with Json_encode. Use and storage are more flexible.
Forward for Weibo
The personal idea is that there is a relational table that is forwarded to a relational data each time, because there is no problem of forwarding the building.
Refer to the data structure design of the forum