I need to have a database that starts with a table called "User" that needs to self reference itself and will have a very deep graph of related objects. It will need to be like the left side of the image below (disregard the right side).
I will also need to traverse through this graph both up and downwards in order to calculate percentages, totals, etc. In other words I'll need to travese the entire graph in some cases.
Is this possible and/or how is it done? Can traversing be done right in the LINQ statement? Examples?
EDIT: I'm basically trying to create a network marketing scenario and need to calculate each persons earnings.
Examples:
- To be able to calulate the total sales for each user under a specific user (so each user would have some sort of revenue coming in).
- Calculate the commission at a certain level of the tree (e.g. if the top person had 3 people below them each selling a product for $1 and the commission was 50% then there would be $1.50.)
- If I queried the image above (on the left) for "B" I should get "B,H,I,J,N,O"
Hopefully that helps :S