Possible Duplicate:
What is the best way to store a tree structure in a relational DB?
I am creating a software which allows multiple login and there is parent child relationship.
Here is an example of my structure,
=> Admin (can create normal customers and level 1-3 resellers)
=> reseller level 3(can create level 1-3 resellers)
=> reseller level 2 (can create level 1-2 resellers)
=>reseller level 1 (can only create level 1 resellers)
Now a level 3 reseller wants to see all of the resellers which he created for all levels and also their children. Similarly that procedure will go for level 2 and 1 resellers. What would be the best approach to maintain this structure in MYSQL as I cannot save parent_id
- there can be unlimited parents.