How do you design a database similar to commenting on nested replies?

Source: Internet
Author: User

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

  • 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.