I'm working on building a tree structure in MySQL and have been experimenting with different ways of representing the data. However, no matter how I slice it, there are shortcomings.
The nested sets model allows me to easily select entire branches of the tree - which I need to do. However it is not so easy to select immediate children of a node.
The adjacency list model is great for getting immediate children, but not so good for returning entire branches of the tree.
I'm wondering, is there anything particularly bad about building a tree structure like this:
TABLE: Tree
ID
name
lft
rgt
parentID
So what I have is the adjacency list model and the nested sets model all in the same table. That way I can use either / or, depending on the circumstances of what I am selecting for.
What are peoples' thoughts? Is this allowed? (Peanut butter and chocolate together at last?) Or is this considered bad design?
Thanks in advance,