嵌套集合模型排序 [英] nested set model sorting

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

问题描述

yo

在此页面上的什么是在关系数据库中存储层次结构数据的选项是什么?存储层次结构的选项有一个很棒的比较.对我来说,嵌套集似乎是最好的,但其中提到需要特定的排序顺序".谁能解释这到底意味着什么?仅通过ID对它们进行排序,我是否能够快速获得上升/下降的排序列表?即使我要在其他列上使用索引进行排序?

on this page What are the options for storing hierarchical data in a relational database? there is an awesome comparison of options for storing hierarchies. For me it looks like nested set is the best, but there it mentions "Requires a specific sort order". Can anybody explain what exactly does that imply? Will I be able to get a sorted list of ascendants/descendants fast only I sort them by id? Even if I have indexes on other columns that I'm trying to use for sort?

推荐答案

在嵌套集模型中,树结构由遍历节点的顺序隐含.

In the nested set model, the tree structure is implied by the order in which the nodes are traversed.

如果要与创建树的排序顺序不同,则必须先读取结果,然后在第二步中对其进行手动排序.(从表中读取行后,索引不再有用.)

If you want a sort order different from that for which the tree was created, you have to read the results first, and then sort them manually in a second step. (After rows have been read from a table, indexes are no longer useful.)

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

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