I'm developing an MLM/Pyramid relation database design. I'm struggling on how to connect them and get the correct design.
So basically for example If Customer 1 recruits Customer 2 and Customer 3 he will get 50$ each
then if Customer 2 or 3 recruits Customer 4 and Customer 5 then Customer 1 will get 25$ each
then if Customer 4 or 5 recruits Customer 6 and Customer 7 then Customer 1 will get 15$ each
then if Customer 6 or 7 recruits Customer 8 and Customer 9 then Customer 1 will get 10$ each
then if Customer 8 or 9 recruits Customer 10 and Customer 11 then Customer 1 will get 5$ each
then if Customer 10 or 11 recruits another one customer 1 won't get any referral fee
There is no limit on how many they can recruit.
Also, this referral system applied to all customers.
So Since Customer 2 or 3 recruits Customer 4 and 5 then Customer 2 or 3 will get the first level 50$ and so on and so forth.
Now I'm trying to create a relation table for this and I'm using the child and parent pattern but I think it's not applicable since I would lose connection on lower levels.
id | user_parent | user_child | amount |
---|---|---|---|
1 | customer1 | customer2 | 50 |
2 | customer1 | customer3 | 50 |
3 | customer2 | customer4 | 50 |
4 | customer2 | customer5 | 50 |
This is where I'm lost how can I tell that customer1 will get 25$ since customer 2 recruits customer 4 and 5?