怎么才能更好的理解树形啊
项目中需要用到树形目录,老是理解不来。怎么才能更直观的理解他啊~!
回复讨论(解决方案)
怎么才叫直观呢?
http://bbs.csdn.net 的侧边栏,算不算直观?
不理解原理吗?
怎么才叫直观呢?
id name sysno
1 小黑 0
2 小白 1
3 小红 2
4 小花 2
5 小蓝 1
6 小黄 0
树形是怎么样的呢? 有个例子就能是最直观的了
不理解原理吗?
是的呢~
http://bbs.csdn.net 的侧边栏,算不算直观?
嗯嗯
但是,怎么说呢。具体对应的那些,不理解的呢。
就比如说,在下拉后,怎么判断判断哪些能继续下拉,哪些不能的呢~
1 小黑 0
- 2 小白 1
-- 3 小红 2
-- 4 小花 2
- 5 小蓝 1
6 小黄 0
1 小黑 0
- 2 小白 1
-- 3 小红 2
-- 4 小花 2
- 5 小蓝 1
6 小黄 0
介个~~~有点抽象~~~
哪个是最上级,那几个是同级的啊?
1 小黑 0
- 2 小白 1
-- 3 小红 2
-- 4 小花 2
- 5 小蓝 1
6 小黄 0
介个~~~有点抽象~~~
哪个是最上级,那几个是同级的啊?
第三列,0,1,2就是对应的层级
设计数据库时,就可以用一个字段放层级id,再用一个字段放上一级的层级id
1 小黑 0
- 2 小白 1
-- 3 小红 2
-- 4 小花 2
- 5 小蓝 1
6 小黄 0
介个~~~有点抽象~~~
哪个是最上级,那几个是同级的啊?
第三列,0,1,2就是对应的层级
设计数据库时,就可以用一个字段放层级id,再用一个字段放上一级的层级id
1
-2
--3
6
-5
--4
是不是这样的了呢?
数据产生时,谁是谁的下级,是你指定的
并且在保存时都根据预设的算法留有锚点
比如你 #4 示例的就是 “邻接列表算法” 的数据结构

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In-depth understanding of the use of Linux pipes In the Linux operating system, pipes are a very useful function that can use the output of one command as the input of another command, thereby conveniently realizing various complex data processing and operations. A deep understanding of how Linux pipes are used is very important for system administrators and developers. This article will introduce the basic concepts of pipelines and show how to use Linux pipelines for data processing and operations through specific code examples. 1. Basic concepts of pipes in Linux

The 23h2 version and the 22h2 version in the Windows 11 system will be released in 2023 and 2022 respectively. Generally speaking, system updates are getting better and better. The editor also believes that the 23h2 version is better than the 22h2 version. Which one is better, win1123h2 or 22h2? Answer: win1123h2 is better. According to reports, win1123h2 is a cumulative version update from 22h2 to the next version, and they are all the same platform. This means that there are no compatibility issues between the two versions. It is recommended that you update them in time. The win1123h2 version brings us many practical features, such as the never-merge mode for taskbar window applications. There are more

Comments are a very important part of Go programming. Comments can help programmers better understand the logic, purpose, and details of the code, thereby improving the readability and maintainability of the code. This article will introduce the importance of comments in the Go language, and combine it with specific code examples to illustrate how comments help code understanding. First, let's look at a simple Go program example: packagemainimport "fmt" funcmain(){/

How to correctly understand the value passing method in PHP PHP is a scripting language widely used in Web development, and the parameter passing methods in PHP mainly include value passing and reference passing. And understanding how values are passed in PHP is crucial to writing efficient code. This article will discuss the value passing method in PHP in detail and use specific code examples to help readers better understand. The basic concept of value passing method is to copy the value of a variable and pass it to a function or method. Operations on the value within the function will not affect it.

To deeply understand the strings.Split function in the Go language documentation, specific code examples are required. In the Go language, string operations are a very common requirement. Among them, the strings package is a standard package provided by the Go language and provides a wealth of string processing functions. Among them, the strings.Split function is one of the commonly used functions. Its function is to split a string into a string slice according to the specified delimiter. Before we officially dive into the strings.Split function,

As the complexity of modern web applications continues to increase, code logic is becoming more and more complex. To solve this problem, middleware is becoming more and more popular in modern web development. ThinkPHP6 is a popular PHP framework that also supports middleware. In this article, we will discuss the basics and practical uses of ThinkPHP6 middleware. What is middleware? In web development, middleware refers to a way of processing HTTP requests and responses. When the client sends a request to the server,

Go language is a concise and powerful programming language with unique design and features in many aspects. One of the most impressive features is the range keyword, which is used to iterate over data structures such as arrays, slices, maps, and channels. The flexibility and convenience of range make it easy to traverse complex data structures, but many people are confused about how it works. This article will explain how range works in a simple and in-depth way, and use specific code examples to help readers better understand. First, let's look at a simple example

SELinux (Security-EnhancedLinux) is a security module that implements Mandatory Access Control (MAC) in Linux systems. It enforces security policies by applying labels to system objects (files, processes, etc.) for more fine-grained access control. SELinux has three working modes: Enforcing, Permissive and Disabled. This article will introduce these three modes in detail and provide specific code examples. 1
