Home  >  Article  >  Backend Development  >  如何才能更好的理解树形

如何才能更好的理解树形

WBOY
WBOYOriginal
2016-06-13 12:01:47990browse

怎么才能更好的理解树形啊
项目中需要用到树形目录,老是理解不来。怎么才能更直观的理解他啊~!
------解决方案--------------------
http://bbs.csdn.net    的侧边栏,算不算直观?
------解决方案--------------------
1        小黑           0
- 2        小白           1
-- 3        小红           2
-- 4        小花           2
- 5        小蓝           1
6        小黄           0

------解决方案--------------------

引用:
Quote: 引用:

1        小黑           0
- 2        小白           1
-- 3        小红           2
-- 4        小花           2
- 5        小蓝           1
6        小黄           0



介个~~~有点抽象~~~


哪个是最上级,那几个是同级的啊?


第三列,0,1,2就是对应的层级
设计数据库时,就可以用一个字段放层级id,再用一个字段放上一级的层级id
------解决方案--------------------
没有 - 的是顶级
 - 多的是 - 少的下级
一样多的是同级
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn