Thanks Alan.. that sure gives me the right direction to work in. - Aseem.
----- Original Message ----- From: "Alan Wolfe" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, November 06, 2003 3:19 PM Subject: Re: Witango-Talk: Multi-tier Referral Program > Well Aseem, > > It looks like you have some work cut out for you! > > What your trying to do is somewhat complicated but very doable. Im not sure > if this matches what you need to do, but if not hopefully it will inspire > some ideas. > I think how id go about doing this would be storing these tree structures in > a table. > > The table would have the columns: > UserID - a unique id identifying the person > Parent - the unique id of the person who refered this person > > Lets say you are the first person in...the top of the tree. Lets also say > your UserID was 1 for simplicity. > > There would be 1 row in the table (Parent is empty (NULL)) > UserID Parent > 1 > > Then lets say you refered me and my UserID is 2. The table would then look > like this: > > UserID Parent > 1 > 2 1 > > Then lets say I refered my friend who is UserID 3. > > UserID Parent > 1 > 2 1 > 3 2 > > Then lets say you refered UserID 4 and 5 and I refered UserID 6. > > UserID Parent > 1 > 2 1 > 3 2 > 4 1 > 5 1 > 6 2 > > So, at the moment, if we wanted to know who UserID 1 refered (thats you), > we: > > select UserID from TreeTable where Parent=1 > > and we get UserID 2,4,5 which are the people you refered. Pretty cool? > > Now lets say UserID 3 refered someone and made some money. > > To figure out the parent of UserID 3 to figure out who to pay you do similar > sql: > > select Parent from TreeTable where UserID=3 > > which results in 2. So UserID 2 gets whatever payment they should get. > > Next we want to go to the next level up to pay that person to. > > select Parent from TreeTable where UserID=2 > > which results in 1. So UserID 1 gets the payment they deserve. > > Now we need to go up another level so... > > select Parent from TreeTable where UserID=1 > > which results in NULL (or empty results). That means we hit the top of the > tree and should stop. > > So...when someone refers someone, you use this method to walk up the tree 5 > steps (or until you run out of parents), giving the people the proper cut of > the profit that they deserve. > > Make sense? > > ----- Original Message ----- > From: "Aseem Mal" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, November 06, 2003 1:51 PM > Subject: Witango-Talk: Multi-tier Referral Program > > > > Hi. > > I wish to develop a Multi-tier Referral Program system. The First person > > who starts the referral chain needs to be disconnected from the chain when > > it reaches the fifth-tier. At that point the Second person becomes the > > Primary. It goes on till the seventh tier. > > I am not sure how the referral code should be assigned and how to > > disconnect after level-five of the chain is reached. > > After being disconnected, the person stops reciving commissions. > > Any ideas will be appreciated. I am attaching a word doc that contains > > answers to all your questions. > > Still, Let me know if you have any questions. > > Thanks, > > Aseem Mal. > > > > ________________________________________________________________________ > > TO UNSUBSCRIBE: Go to http://www.witango.com/maillist.taf > > ________________________________________________________________________ > TO UNSUBSCRIBE: Go to http://www.witango.com/maillist.taf ________________________________________________________________________ TO UNSUBSCRIBE: Go to http://www.witango.com/maillist.taf
