bigeagle】 于 2000-12-6 14:43:38 加貼在 Joy ASP ↑:
下面這種方法是大怪獸和怡紅公子現(xiàn)在采用的方法
create table forum ( ID int NOT NULL IDENTITY,/*帖子序列號*/ rootID int NOT NULL, /*根帖子序列號*/ parentID int NOT NULL default=0,/*雙親帖子序列號*/ indent tinyint,/*縮進(jìn)*/ order tinyint,/*同主題帖子排序*/ username varchar(40) NOT NULL,/*用戶名*/ time daytime NOT NULL,/*貼帖子時(shí)間*/ IP varchar(15) NOT NULL,/*發(fā)帖子的IP*/ subject varchar(60) NOT NULL,/*帖子題目*/ text text,/*帖子正文*/ bytes int,/*帖子字?jǐn)?shù)*/ status bit,/*狀態(tài)*/ hits tinyint,/*hit數(shù)*/ primary key(ID) /*主關(guān)鍵字*/ )
簡單地說用3個(gè)列描述層次結(jié)構(gòu) 1.rootid 2.indent 3.同一個(gè)root下,order_no
如
1號貼 2號貼 3號貼 5號貼 4號貼 6號貼
這個(gè)結(jié)構(gòu)的存儲格式如下 id rootid indent 一個(gè)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,"一個(gè)root下,order_no"排序, 按indent縮進(jìn) 即得樹狀到帖子列表
indent是4byte整數(shù),從0開始的話,支持2147483648層 你要是定成numberic,那我也說不清支持幾層
|