0

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?

Gorhell
  • 41
  • 1
  • 8
  • Does this answer your question? [How to create a MySQL hierarchical recursive query?](https://stackoverflow.com/questions/20215744/how-to-create-a-mysql-hierarchical-recursive-query) – philipxy Oct 30 '21 at 03:34
  • And you will use MLM to do what? – Rick James Oct 30 '21 at 04:21
  • Thanks for the link this helps a lot I'll check on it. The MLM is a project that I've been working on for a small business here locally – Gorhell Oct 30 '21 at 05:01
  • With this approach how can I get the amount difference for each level? the 50,25,15,10,5? – Gorhell Oct 30 '21 at 06:00

0 Answers0