At present, in the user table with the PID relationship between the subordinate, the statistics of a user's subordinate total number of the recursive query to 19, but later found in the number of users subordinate to the site directly to drag the dead, how should we deal with? Thank you..
Reply content:
At present, in the user table with the PID relationship between the subordinate, the statistics of a user's subordinate total number of the recursive query to 19, but later found in the number of users subordinate to the site directly to drag the dead, how should we deal with? Thank you..
Add a path field
This is actually in a lot of e-commerce station also encounter this kind of infinite class classification problem, design we sometimes why add a PID to identify sub-class, to the final query all have to kill themselves.
This is the time to modify the database table structure, allowing data redundancy to solve the problem.
Add:
The current table can be added to a column called Pid_list, which is stored in the format of 1 for the highest level of 2 is on-line, 3 for their own ID.
You can also add a level number that identifies the level at which you belong to depth,1 level 1, corresponding to pid_list.
After adding these, we will be more convenient to inquire.
Reference no series classification
You can add a path field
Increase the total number of children directly on each user record, a->b->c->d if C invites D, update the ABC three plus 1. This task can be processed asynchronously if it is not real-time.