I am working on creating a tree structure in MySQL and have been experimenting with various ways of representing data. However, no matter how I cut it, there are drawbacks.
The nested set model allows me to easily select whole tree branches - what do I need to do. However, it is not so easy to select immediate children from node.
The adjacency list model is great for getting immediate children, but not so good for returning entire branches of a tree.
I am wondering if there is anything particularly bad about building a tree structure as follows:
TABLE: Tree
ID
name
lft
rgt
parentID
So, I have an adjacency list model and nested model sets all in one table. Thus, I can use either / or, depending on the circumstances from which I choose.
What are people's thoughts? It is allowed? (Peanut butter and chocolate together at last?) Or is this considered a poor design?
Thanks in advance,
source
share