A
A
Artem00712017-07-18 11:56:15
PHP
Artem0071, 2017-07-18 11:56:15

How to organize a database and work with it?

How to organize the database so that you can create comments and replies to them?
What I thought:
Create a comments table with fields: id | answer_id | post_id |
comment id - key; answer_id - can be NULL, or the id of the comment being answered, post_id - post ID
BUT
First we do Then we find out which comments are replies to the comment. If there are 10 comments-answers, then the cycle will have to be used 10 times. How can this be made easier? (using PHP)select * where post_id = 1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-07-18
@webinar

How many levels of nesting. Your option at 2-3 levels will already be very resource-intensive. I would look towards nestedSets

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question