欢迎光临
我们一直在努力

bbs树型结构的实现方法(二)_asp实例

建站超值云服务器,限时71元/月

bigeagle】 于 2000-12-6 14:43:38 加贴在 Joy ASP ↑:

下面这种方法是大怪兽和怡红公子现在采用的方法

create table forum
(
ID int NOT NULL IDENTITY,/*帖子序列号*/
rootID int NOT NULL, /*根帖子序列号*/
parentID int NOT NULL default=0,/*双亲帖子序列号*/
indent tinyint,/*缩进*/
order tinyint,/*同主题帖子排序*/
username varchar(40) NOT NULL,/*用户名*/
time daytime NOT NULL,/*贴帖子时间*/
IP varchar(15) NOT NULL,/*发帖子的IP*/
subject varchar(60) NOT NULL,/*帖子题目*/
text text,/*帖子正文*/
bytes int,/*帖子字数*/
status bit,/*状态*/
hits tinyint,/*hit数*/
primary key(ID) /*主关键字*/
)

简单地说用3个列描述层次结构
1.rootid   2.indent  3.同一个root下,order_no

1号贴
2号贴
3号贴
5号贴
4号贴
6号贴

这个结构的存储格式如下
id rootid indent 一个root下,order_no
1 1 0 0
2 1 1 1
3 1 2 2
4 4 0 0
5 1 1 3
6 4 1 1

按rootid,"一个root下,order_no"排序,
按indent缩进
即得树状到帖子列表

indent是4byte整数,从0开始的话,支持2147483648层
你要是定成numberic,那我也说不清支持几层

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » bbs树型结构的实现方法(二)_asp实例
分享到: 更多 (0)

相关推荐

  • 暂无文章