I've to develop a multilevel marketing web app. In this Im facing an issue, please help me in this issue
child1 child2 child3 child4 child5 child6 child7
child11 child22 child33 child44 child55 child66 child77
each child can have 7 childs and upto 7 levels.
my table design is as following
id | parent_id | position | level
2 | 1 | 0 | 1
3 | 1 | 1 | 1
4 | 1 | 2 | 1
5 | 1 | 3 | 1
6 | 2 | 1 | 1
My problem is how to find a vacant position for given parent.
eg: when member 2 (id=2) is adding a new member i've to add the new member 7 in to a vacant position
under him or under any of his descendants.
Is there any way find a vacacnt position ? Or any alternate database design for this purpose ?
Thanks & regards
Have a read of this SitePoint Article:
It discusses two methods of storing hierarchical data in a relational database