Nested Set in Laravel is the today’s topic. The nested set model is to number the nodes according to a tree traversal, which visits each node twice, assigning numbers in the order of visiting, and at both visits. That leaves two numbers for each node, which are stored as two attributes. Querying becomes inexpensive: hierarchy membership can be tested by comparing these numbers. Updating requires renumbering and is therefore expensive.

What is Nested Set

Nested sets or  Nested Set Model(NSM) is the way to store the hierarchical data in a relational table efficiently.

Usecase

NSM shows good performance when the tree is rarely updated. It is created to be fast for getting related nodes.

It is ideally suited for building multi-depth menu or categories for the shop.

#laravel #nested set

Nested Set in Laravel Tutorial
23.45 GEEK