A
A
Alexander2018-02-16 18:07:11
SQL
Alexander, 2018-02-16 18:07:11

Hierarchical data storage structure. How to find the number of children of an element?

I need to somehow store the binary tree in the database. It can be Nested sets or just a reference to the parent, I don't know which is better. It is necessary to solve the problem of showing the number of descendants of each element on each side. At the same time, descendants can and will be added, but I would not like to re-read the whole tree, since it can grow large.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yerlan Ibraev, 2018-02-19
@mad_nazgul

Count and think.
Nested Set - fast reading, but long insertion
ParentID - fast insertion and long reading
Without knowing what kind of tree you will have and what tasks it will solve, it is impossible to say unequivocally which is better.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question