我需要一个5个层次的用户注册到一个网站。每个用户都是由另一个用户邀请的,我需要了解一个用户的所有后代。也是用户的祖先。
我想到了2种解决方案。
    ancestor_id  descendant_id  distance
    1            1              0
    2            2              0
    3            3              0
    4            4              0
    5            5              0
    6            6              0
    2            3              1   user_id ancestor_level1_id ancestor_level2_id ancestor_level3_id ancestor_level4_id ancestor_level5_id
   10      9                  7                  4                  3                  2
   9       7                  4                  3                  2                  1这些主意好吗?
我知道“邻接列表模型”和“修改的预序树遍历算法”,但是这些是“推荐”系统的好解决方案吗?
我需要在此树上执行的查询是:
https://stackoverflow.com/questions/5995823
复制相似问题