How to design a database similar to the comment nested reply?

Source: Internet
Author: User
In the first case, comment on nested replies. In this case, how is the database designed? I have two ideas: one is to save the reply comment id. If this is not the case, every nested comment must iterate all the parent classes, and the performance is poor. The second idea is to save the IDs of all parent classes, using...First case

Comment nested reply. In this case, how is the database designed?

I have two ideas: one is to save the reply comment id. If this is not the case, every nested comment must iterate all the parent classes, and the performance is poor. The second approach is to save the IDs of all parent classes, which are separated by a comma (,) or a broken number, and exist in a field.

Case 2

How is the database designed for Weibo forwarding?
I also have two ideas: one is the id of the person who saves the forwarding, the other is the id of the person who previously forwarded the microblog, and the other is all the content that stores the forwarding. Which one is more suitable?

There are no more appropriate ideas .? Please kindly advise.

Reply content:First case

Comment nested reply. In this case, how is the database designed?

I have two ideas: one is to save the reply comment id. If this is not the case, every nested comment must iterate all the parent classes, and the performance is poor. The second approach is to save the IDs of all parent classes, which are separated by a comma (,) or a broken number, and exist in a field.

Case 2

How is the database designed for Weibo forwarding?
I also have two ideas: one is the id of the person who saves the forwarding, the other is the id of the person who previously forwarded the microblog, and the other is all the content that stores the forwarding. Which one is more suitable?

There are no more appropriate ideas .? Please kindly advise.

Comment on Building

First of all, this form is rare, and features are simplified. It is not applicable to the trend of mobile products.
In terms of implementation, we used to record the Comment number that he replied to in each piece of data. After reading your questions, I personally feel that your second implementation adopts redundant storage and records the comment numbers of all superiors. This is a good note and provides better performance. When storing multiple values, you used to separate them with commas. Now you prefer to store them with json_encode. Use and Storage are more flexible.

Weibo-based forwarding

My personal idea is that there is a relational table, and each time it is forwarded as a relational data, because there is no architecture issue in the forwarding.

Refer to the data structure design of the Forum.

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.