S
S
SM_ST2021-08-09 22:35:46
MySQL
SM_ST, 2021-08-09 22:35:46

Designing a comment system in mysql?

Hello!

Need help and advice!

I’m making a multi-level comment system like here,
611181e073a40602178183.png
611181ea32921679583718.png

but there’s a blunt right away - how to implement infinite nesting without a huge number of requests to display this kind of structure, as in screenshots

, two options come to mind:

1) Comment table Like / dislike comment
table
comments - id, parent_id, post_id, text

comment_likes - comment_id, user_id, post_id, type(1- like/ 0 -dislike)


but here the problem immediately pops up in a large number of requests and recursion

2)
Table of comments Table
comments - id, post_id, text
of replies to comments
comment_replies - comment_id, reply_id, level
Table of likes / dislikes in comments
comment_likes - comment_id, user_id, post_id, type(1- like/ 0 -dislike)


Maybe there is a better option?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lander, 2021-08-10
@usdglander

https://habr.com/ru/post/153861/
The article gives the names of other methods for constructing such trees. See which one suits you best.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question