K
K
KIN19912018-10-08 15:18:48
Django
KIN1991, 2018-10-08 15:18:48

What is the best tree structure for implementing multi-level comments and why?

Hello everybody. There is a task to implement a system of multi-level comments (on the news portal) on Django, I would like to know which tree structure is best suited and why?
I singled out three structures for myself:
1) Adjacency model
2) Nested Sets
3) Closure Table.
What is better to choose for the task described by me above?
I want to note right away that the availability of ready-made solutions is not a big plus for me.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Kitaev, 2018-10-08
@deliro

MPTT. Because:
1) There is a django-mptt package that already has everything
2) Almost all the selections that come to your mind are made in one request.
MPTT is an extension of nested sets. Of the minuses, everything is the same as in nested sets - non-compliance with referential integrity, heavy insert

M
maksam07, 2021-11-01
@maksam07

Hey! So which option did you end up choosing? What do you use? If you use any at all :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question