MySQL表结构问题 [英] MySQL table structure question

查看:75
本文介绍了MySQL表结构问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在四处寻找SO,并且看到了很多有关类别树菜单的问题,并且想知道我的一个或多个MySQL表是什么样子,因此我可以添加许多类别,减少子类别的数量,并在它们上显示我的网站.

I've been looking around on SO and have been seeing a lot of questions about category tree menus and was wondering how would my MySQL table or tables look like so I can add many categories and count less sub categories and display them on my web site.

请注意,我将使用PHP& MySQL.

Note I will be using PHP & MySQL.

推荐答案

我通常使用与以下结构相似的结构:

I usually use a structure similar to the one below:

Category
--------
CategoryId
CategoryName
ParentCategoryId

MySQL在此主题上有一篇不错的文章,在MySQL中管理分层数据,如果您有兴趣对此主题进行更多研究.它进入此结构,并为您提供一些示例查询,询问如何获取特定情况下所需的数据.

MySQL has a decent article on this subject, Managing Hierarchical Data in MySQL, if you are interested in doing some more research on the subject. It goes into this structure and gives you some sample queries on how to get the data you want for specific scenarios.

这篇关于MySQL表结构问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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