Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我必须将博客风格的评论存储在数据库中。每个评论都可以有一个父评论。
我正在使用一个名为“parentComment”的列来做这件事,当它是顶级评论时它有一个空值,或者如果它是对另一个评论的响应则有一个值。
检索评论及其所有子项的最有效方法是什么?
一种非常常见的技术是与树的“根”也有(重复的,间接的)关系,这意味着您可以在一个整洁的选择中选择完整的树。否则它很快就会变脏。