How to implement a nested comment system?

后端 未结 1 358
耶瑟儿~
耶瑟儿~ 2021-01-02 11:43

What would be the ideal way to implement this sort of thing? The idea I have in my head right now is to have a comments table and have each comment have a thread identifier

相关标签:
1条回答
  • 2021-01-02 12:04

    Look at Managing Hierarchical Data in MySQL, specifically the section called "Nested Set Model". You may have to read through it a few times before it makes sense (I did) but it's worth it. It's a very powerful way to work with nested data and retrieve the parts you want with only one query.

    On the downside, for updates you have to do a lot more work.

    0 讨论(0)
提交回复
热议问题