使用sql数据的二叉树结构 [英] binary tree structure using sql data

查看:174
本文介绍了使用sql数据的二叉树结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在做MLM Web项目,我应该以二叉树结构显示用户信息数据.在这里,每个父节点都有两个子节点,例如左右,每个子节点又包含两个子节点,反之亦然,我应该从sql数据库中显示所有这样的用户信息.

请帮助我如何创建二叉树.

Hi
I am doing MLM web project, I should display user information data in binary tree structure. Here each parent node have two child node like left and right again each child node contain two child nodes and again vise versa , I should display all the user info like this from sql database.

please help me how to create binary tree.

推荐答案

表结构为

PersonID ParentID LChildID RChildID

Id父ID为null,则为根
如果Left或Right ID为null,则可以添加新的Child.

一切顺利.
Table Structure is

PersonID ParentID LChildID RChildID

Id Parent ID is null Then Its a Root
If Left Or Right ID is null Then its can add new Child.

All the best.


这篇关于使用sql数据的二叉树结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆