Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the model, lft, and rght fields used in the acos table?

What are the cakePHP usages/meanings of the model, lft, and rght fields in a acos table? Similarly, what are the usages/meanings of the lft and rght fields in a aros table?

like image 690
takabanana Avatar asked Apr 24 '10 17:04

takabanana


1 Answers

They are required by the Modified Pre-order Tree Traversal data modelling technique commonly used for modelling hierarchical data. They allow quick single query ways of selecting all nodes in a branch. This means you don't have to use recursion and multiple queries. I.e.

SELECT * FROM tree WHERE left > 4 AND right < 8

Where 4 and 8 might be the left and right values of a parent node, whose children and grand children you want to extract.

like image 69
neilcrookes Avatar answered Oct 17 '22 13:10

neilcrookes