java - Do I need to set childrenID when setting parentID and ID in the database?
PHP中文网
PHP中文网 2017-05-27 17:41:52
0
2
682

I want to traverse a tree recursively, but I feel that using parentID and ID cannot determine whether there are child nodes and cannot traverse it. I don’t know if I need to add a childrenID field

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
phpcn_u1582

If you only represent a tree, a single table of parentID and ID is enough; it is called: adjacency list.

習慣沉默

Then add a treepath. Record the path from each node to the root node

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template