Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
VeriSign Code Signing Digital Certificates provides assurance to end users. Read about this and more in the free white paper: “How to Digitally Sign Downloadable Code for Secure Content Transfer.” Learn More!
  #1  
Old May 1st, 2003, 12:20 PM
aqeelahmad aqeelahmad is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: Pakistan
Posts: 1 aqeelahmad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
database design problem

i have to design database for a mlm (multi lavel marketig) project.
it starts from one member... and then that person refers two people... and then every new comer refers more two.. in this way .. a BINARY TREE starts growing... by binary it means that... every entity has two childs.... hope you are getting it....
its like.


........1
....../...\
.....2.....3
..../\....../\
...4..5....6..7
../....\../....\
.8......9.10...11

here any member gets commission each time he has 4 new members on his right or left. e.g. member(7) gets a new member(11) on his right. this way member(1) now has 4 members on his right side and commission will be added for member(1).

........1
....../...\
.....2.....3
..../\....../\
...4..5....6..7
..............\
...............(11)


and when member(11) gets 4 new members like this:

........1
....../...\
.....2.....3
..../\....../\
...4..5....6..7
..............\
...............11
............./....\
..........(12)....(13)
.............\.......\
...........(14)......(15)

now member(1) will get commission for 4 new members(12,13,14,15) (he has already got commission for 3,6,7 and 11 and he needs one more member on his left to get new commission for 4 new members). and mebmer(3) will get commission for 4 new members on his right(7,11,13,15).

now I dont know how to design database for this problem that is efficient each time a new member is added to the tree, so that it will add commission accurately upward in the tree as described above.

Last edited by aqeelahmad : May 1st, 2003 at 12:33 PM.

Reply With Quote
  #2  
Old May 1st, 2003, 12:56 PM
NoXcuz's Avatar
NoXcuz NoXcuz is offline
Wiking
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Sep 2000
Location: Sweden
Posts: 3,608 NoXcuz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 49 m 27 sec
Reputation Power: 11
I hate that pyramid stuff...
Anyway, look if this applies to you (checkout the links at the bottom of the page as well). -> http://www.sitepoint.com/print/1105

//NoXcuz
__________________
UN*X is sexy!
who | grep -i blonde | date; cd ~; unzip; touch; strip; finger; mount; gasp; yes; uptime; umount; sleep

Reply With Quote
  #3  
Old May 8th, 2003, 05:31 PM
rsingleton rsingleton is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: Texas
Posts: 2 rsingleton User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
With the outline you have laid out it is difficult to tell, but are your members going to sign up only 2 new members each and then quit, or will they continually be signing more and more members.

2 Member method:

Members_t
--------------
ID NUMBER(9) pk
Name VARCHAR(?)
Commision NUMBER(7,2)
Father NUMBER(9)
Mother NUMBER(9)

.........1
........./\
........2 3
......./\ /\
......4 7
....../\
.....5 6

Etc.

Multi-tier Pyramid method:

Members_t
---------------
id NUMBER(9) pk
name VARCHAR(?)
commision NUMBER(7,2)
parent NUMBER(9)

Member 1
|- Member 2
| |- Member 3
| |- Member 4
| | |- Member 5
| | |- Member 8
| |
| |- Member 7
|
|- Member 9
|- Member 10

Then all you need to do is write some counting procedures.
Easiest method would be to count the total of child members, divide by 4, then multiply the commision for the member.

If you have to have a right and left side of the tree you can split the info into more tables and join them:

Member_t
-------------
id NUMBER(9) pk
name VARCHAR(?)
commision NUMBER(7,2)

tree_left_t
--------------
id NUMBER(9) pk
parent_id NUMBER(9)
child_id NUMBER(9)

tree_right_t
---------------
id NUMBER(9) pk
parent_id NUMBER(9)
child_id NUMBER(9)

Then run your commision calculations.

Last edited by rsingleton : May 9th, 2003 at 08:43 AM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > database design problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway