I need to build a hierarchical list in a website. There are four levels of information:
我需要在网站上建立一个分层列表。有四个级别的信息:
Categories > Types > Sections > Topics
分类>类型>部分>主题
the id of category is a foreign key for types, the id for types is a foreign key for sections, the id for sections is the foreign key for topics.
类别的id是类型的外键,类型的id是节的外键,节的id是主题的外键。
This structure seemed necessary as there are pages for each of those four kinds of levels. The pages each display the information in each part as well as the children parts.
这种结构似乎是必要的,因为这四种级别中的每一种都有页面。每个页面都显示每个部分的信息以及子部分。
Meaning, you could visit http://localhost/community/category.php?id=1
(or any number between 0 and 20ish) and http://localhost/community/types.php?id=3
etc for each of the other two kinds of information as well.
意思是,您可以访问http://localhost/community/category.php?id = 1(或0到20ish之间的任何数字)和http://localhost/community/types.php?id = 3等每个其他两种信息也是如此。
Could i build a hierarchical list with this sort of structure or would i have to do it like a traditional hierarchical mysql structure?
我可以用这种结构构建一个分层列表,还是像传统的分层mysql结构一样呢?
1 个解决方案
#1
2
I've posted this link more than once before: mikehillyer.com/articles/managing-hierarchical-data-in-mysql ...
我之前不止发布过这个链接:mikehillyer.com/articles/managing-hierarchical-data-in-mysql ...
I have always used the The Adjacency List Model; as long as one of the listed limitations is not going to be an issue with your particular data set
我一直使用The Adjacency List Model;只要列出的限制之一不会成为您的特定数据集的问题
#1
2
I've posted this link more than once before: mikehillyer.com/articles/managing-hierarchical-data-in-mysql ...
我之前不止发布过这个链接:mikehillyer.com/articles/managing-hierarchical-data-in-mysql ...
I have always used the The Adjacency List Model; as long as one of the listed limitations is not going to be an issue with your particular data set
我一直使用The Adjacency List Model;只要列出的限制之一不会成为您的特定数据集的问题