多级类表结构 [英] Table structure of multilevel category

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

问题描述

我需要以下类别和子类别的表结构:

I am required a Table structure for the following category and sub categories :

主类别第一个子级第二个子级第三个子级
电子=>计算机=笔记本电脑=> Dell
类别和子类别的完美表格是什么?

main category 1st child 2nd child 3rd child Electronics => Computer => Laptop => Dell what will be the perfect table for the category and subcategories ?

推荐答案

做它

id      |   name        |   parent_id
---------------------------------------
1       |   Electronics |   0
2       |   Computer    |   1
3       |   Laptop      |   1
4       |   Dell        |   1
5       |   Dual Core I |   3

0表示它是父类别。计算机包含1作为父类,这意味着它是电子的孩子。双核我包含3意味着它是笔记本电脑的孩子。这样,您可以拥有任意多个级别。

0 means it is a parent category. Computer contains 1 as parent category which means it is child of Electronics. Dual Core I contains 3 means it is child of Laptop. This way you can have as many levels as you want.

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

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