i am building an affiliate system and i have stacked with the design of the database in one part. I dont know how to keep track on that who recruited whom. Lets say we have something like this:
All this goes this way: 1.Jon recruited Alex, Alex Recruited Jim, Marko and Johny. 2.Jon recruited Pit, Pit Recruited Sara, Gabriella and Antonio. 3.Jon recruited Maja, Maja recruited Agon. Agon can recruit some one ells and that one can recruited someone ells, this goes in infinite depth.
Does any one has an idea how to solve this problem. How to design tables ?
Just use a self referencing table, with an ID and a recruitedbyid:
ID Name RecruitedBy 1 Jon Smith null 2 Alex Del 1 3 Marko Polo 1 ...
You did not mention which database you are using, but SQL Server 2008 has a hierarchical data type suited for just these situations, hierarchyid.