I
I
ince2019-03-21 15:30:08
Database design
ince, 2019-03-21 15:30:08

How to store a tree?

There is a task - to store hierarchy of types in a DB.
The classification of types is always changing - elements can be added at any level, the levels themselves can change. In general, anything can happen.
I remembered how we stored trees at the university - we numbered the left and right vertices of the element, I don’t remember exactly what it is called, as shown in the figure 5c9383268004b728348453.png.
The question is how to update this, after adding each element you will have to recalculate all the vertices, is there a native function for this in Oracle?
How to get the immediate children or all children (although the children are easy to get - the value of the left vertex of the child between the left and right of the parent) ?
Who is in the subject, tell me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
longclaps, 2019-03-21
@longclaps

What you painted is called a nested set . Everything is written there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question