The Cusp of Helix

Fertile Forest Model
[C.2: Conventional Models]

Hybrid Model

Conventional four models has an interesting trade-off. The table below is a list whether can describe query to find a subtree and adjacency (parent and child) node smartly. Expresses an evaluation by ABC for expressing the hybrid model.

Model nameFind SubtreeFind Adjacency Node
Adjacency List ModelCAA
Path Enumeration ModelAC
Nested Set ModelAC
Closure Table ModelAC

Closure Table Model and Nested Set Model are excellent in searching subtree, but can not describe query to find adjacency node smartly. In contrast, Adjacency List Mode can not describe query to find subtree, but it exerts the performance to find adjacent nodes worthy of its name.

Against this situation, there is a way of thinking such as:

If finding subtree and adjacent nodes is mutually exclusive and it is difficult to cover with one model, it is better to be caused to coalesce their advantages.

It can be summarized as "the best of both worlds". It is very reasonable. In fact, the part of the library that implements the model storing hierarchical data in RDB is designed to contain two kind of hierarchical structure columns as:

  • Parent column of the adjacency list model
  • Left and right columns of nested set model

Combines the above two, the hybrid model can describe smart query to find both (subtree and adjacent nodes).