分层数据 - 嵌套集模型:MySql [英] Hierarchical Data - Nested Set Model: MySql

查看:203
本文介绍了分层数据 - 嵌套集模型:MySql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是学习如何实现嵌套集合模型,但仍然与其涉及可能是多个类别的一部分的项目的某个方面混淆。在下面的示例中,从 此处 中提取,镜子很多其他例子我遇到了...







当您添加Apples时,如何避免在DB中出现重复,因为它们是多色的(即红色,黄色,绿色)?


<你不要避免重复,苹果(或苹果的引用)将在你的树中放置两次,否则它不会是一棵树,而是一棵树。图形。如果你构建一个... Swing JTree或一个HTML树,你的问题同样适用。)



嵌套集模型只是一种有效的方法推送和遍历树结构在关系DB中。它不是数据结构本身。它在MySQL用户中更受欢迎,因为MySQL缺少处理树结构的功能(例如像Oracle提供的那样)。



干杯!


I am just learning how to implement the Nested Set Model but still have confusion with a certain aspect of it involving items that may be part of multiple categories. Given the example below that was pulled from HERE and mirrors many other examples I have come across...

How do you avoid duplication in the DB when you add Apples since they are multi-colored (i.e. Red, Yellow, Green)?

解决方案

You do not avoid duplications and the apple (or a reference to the apple) will be placed twice in your tree otherwise it won't be a tree but rather a graph. Your question is equally applicable if you build a... Swing JTree or an HTML tree ;).

The nested set model is just an efficient way to push and traverse a tree structure in a relational DB.It is not a data structure itself. It's more popular among MySQL users since MySQL lacks functionality for processing tree structures (e.g. like the one that Oracle provides).

Cheers!

这篇关于分层数据 - 嵌套集模型:MySql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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