I am working on a project which user registration multiples like this.
1st Month -> 1 user
2nd Month -> 4 users comes under the above user
3rd Month -> 16 users (i.e, 4 users comes under each 4 users above )
4th Month -> 64 users (i.e, 4 users comes under each 16 users above )
eg:
1
2 | 2
8 | 8
32| 32
and continues…
Please give me an advice, how to store this in database.
Thanks in advance.
Assuming
user_idis your primary key, create aparentcolumn that contains theuser_idof the parent user. For example:You will also want to create an index on the
parentcolumn so that you can quickly do a reverse lookup (i.e. find all children of a given user).