hierarchical

php / Mysql best tree structure

坚强是说给别人听的谎言 提交于 2019-11-26 11:19:38
I have to build a tree that will contain about 300 nodes inside it. The tree has no depth limitations. So it can have 3 or 15 levels. Each node can have an unlimited number of children. The priority is to get a complete tree / subtree the faster as possible, but I also need to add nodes or move nodes sometimes but not that often. I want to know the best way to store the tree in the database and the best way to retrieve the data, if possible, in php. You can use a Nested Set Model as it yields very efficient queries. Check out Managing Hierarchical Data in MySQL and read the section called

php / Mysql best tree structure

≡放荡痞女 提交于 2019-11-26 02:20:12
问题 I have to build a tree that will contain about 300 nodes inside it. The tree has no depth limitations. So it can have 3 or 15 levels. Each node can have an unlimited number of children. The priority is to get a complete tree / subtree the faster as possible, but I also need to add nodes or move nodes sometimes but not that often. I want to know the best way to store the tree in the database and the best way to retrieve the data, if possible, in php. 回答1: You can use a Nested Set Model as it