Implementing An N-Level Nested Tree In PHP And PostgreSQL, Part 1
A Sample Nested Tree
This web site uses a nested tree to structure the documents and the relationships between the documents. We refer to each document as a node. At time of writing, part of the PhpRiot nested was structured as such:
Title ------------------------ General Resources Code Paste Documentation Books & Publications Apache PostgreSQL MySQL Links Databases Generators Portals
Just by looking at this structure, we can determine the following information:
- The section is called General Resources, and has the children Code Paste, Documentation, Books & Publications and Links.
- Documentation has three siblings: Code Paste, Books & Publications and Links
- PostgreSQL has parent Books & Publications, and is an ancestor of General Resources
- Portals is a descendants of General Resources.
Obviously there is much more that can be determined, but this hopefully demonstrates the point.
Although we refer to each item as a node, beacuse it’s a tree structure you could also use the following terminology:
- A nodes with no children is a leaf
- A node with children is a branch