国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

bbs的數據結構和存儲過程(一)

2019-11-18 20:35:23
字體:
來源:轉載
供稿:網友
/*數據結構*/

/*bbs用戶表*/
if exists(select * from sysobjects where id = object_id('BBSUser'))
drop table BBSUser
go

create table BBSUser
(
id int identity PRimary key ,
UserName varchar(20) default '' not null ,
PassWord varchar(10) default '' not null ,
Email varchar(100) default '' not null ,
Homepage varchar(150) default '' not null ,
Signature varchar(255) default '' not null ,
SignDate datetime default getdate() not null ,
Point int default 0 not null
)

go

create index ix_bbsuser on bbsuser (id , username , password)

/*bbs表情表*/
if exists(select * from sysobjects where id = object_id('Face'))
drop table Face
go

create table Face
(
id tinyint identity primary key ,
Face varchar(30) default '' not null
)
go

/*bbs表*/
if exists(select * from sysobjects where id = object_id('BBS'))
drop table BBS
go

create table BBS
(
id int identity primary key ,
RootID int default 0 not null , --根ID
FatherID int default 0 not null , --父ID
Layer tinyint default 0 not null , --層
OrderNum float(53) default 0 not null , --排序基數
UserID int default 0 not null , --發言人ID
ForumID tinyint default 1 not null , --版面ID
Subject varchar(255) default '' not null , --主題
Content text default '' not null , --內容
FaceID tinyint default 1 not null , --表情
Hits int default 0 not null , --點擊數
ip varchar(20) default '' not null , --發貼IP
Time datetime default getdate() not null , --發表時間
Posted bit default 0 not null --是否精華貼子
)
go

create index ix_bbs on bbs(id , rootid ,layer , fatherid , subject,posted) with DROP_EXISTING
create index ix_bbs1 on bbs(fatherid , forumid) with DROP_EXISTING
create index ix_bbs2 on bbs(forumid , rootid , ordernum) with drop_existing

/*精華區*/
if exists(select * from sysobjects where id = object_id('PostedTopic'))
drop table PostedTopic
go

create table PostedTopic
(
id int identity primary key ,
UserID int default 0 not null , --發言人ID
ForumID tinyint default 1 not null , --版面ID
Subject varchar(255) default '' not null , --主題
Content text default '' not null , --內容
FaceID tinyint default 1 not null , --表情
Hits int default 0 not null , --點擊數
IP varchar(20) default '' not null , --發貼IP
Time datetime default getdate() not null --發表時間
)
go

/*forum版面表*/
if exists(select * from sysobjects where id = object_id('forum'))
drop table forum
go

create table Forum
(
ID tinyint identity primary key ,
RootID tinyint default 0 not null , --根ID
FatherID tinyint default 0 not null , --父ID
Layer tinyint default 0 not null , --層
Title varchar(50) default '' not null , --版面名稱
Description varchar(255) default '' not null , --版面描述
MasterID int default 1 not null , --版主ID
TopicCount int default 0 not null , --貼子總數
Time datetime default getdate() not null , --創建時間
IsOpen bit default 0 not null --是否開放
)
go

insert into forum(rootid , fatherid , layer , title , description , masterid) values(1 , 0 , 0 , "談天說地" , "在不違犯國家法律的情況下,你可以發表你自己的言論。" , 1)
insert into forum(rootid , fatherid , layer , title , description , masterid) values(2 , 0 , 0 , "體育" , "在不違犯國家法律的情況下,你可以對體育發表你自己的評論。" , 1)
insert into forum(rootid , fatherid , layer , title , description , masterid) values(1 , 1 , 1 , "笑話站" , "笑話,讓你在工作間隙輕松一下。" , 1)
insert into forum(rootid , fatherid , layer , title , description , masterid) values(2,2 , 1 , "體育沙龍" , "體育總和評論。" , 1)
insert into forum(rootid , fatherid , layer , title , description , masterid) values(2,2 , 1 , "足球" , "足球評論。" , 1)
insert into forum(rootid , fatherid , layer , title , description , masterid) values(2,2 , 1 , "海牛俱樂部" , "海牛球迷的討論園地。" , 1)

select * from forum

/*論壇通告表*/
if exists(select * from sysobjects where id = object_id('Notify'))
drop table Notify
go

create table Notify
(
ID int identity primary key ,
TopicID int default 0 not null ,
Closed bit default 0 not null ,
)
go
select * from notify
delete from notify where id=5

/***********以下為存儲過程************************************************************/

/*************************************************************************/
/* */
/* procedure : up_GetBBSInfo */
/* */
/* Description: 取得整個論壇的相關信息 */
/* */
/* Parameters: none */
/* */
/* Use table: forum , bbs , bbsuser */
/* */
/* Author: bigeagle@163.net */
/* */
/* Date: 2000/2/3 */
/* */
/* History: */
/* */
/*************************************************************************/

if exists(select * from sysobjects where id = object_id('up_GetBBSInfo'))
drop proc up_GetBBSInfo
go

create proc up_GetBBSInfo
as
declare @ForumCount int
declare @TopicCount int
declare @UserCount int

set nocount on
select @ForumCount = count(*) from Forum where layer <> 0
select @TopicCount = count(*) from BBS
select @UserCount = count(*) from BBSUser

/*取得論壇本身信息*/
select 'ForumCount' = @ForumCount , 'TopicCount' = @TopicCount , 'UserCount' = @UserCount

go
up_getbbsinfo
/*************************************************************************/
/* */
/* procedure : up_GetForumInfo */
/* */
/* Description: 取得指定版面的相關信息 */
/* */
/* Parameters: @a_intForumID */
/* */
/* Use table: forum , bbs , bbsuser */
/* */
/* Author: bigeagle@163.net */
/* */
/* Date: 2000/2/3 */
/* */
/* History: */
/* */
/*************************************************************************/

if exists(select * from sysobjects where id = object_id('up_GetForumInfo'))
drop proc up_GetForumInfo
go

create proc up_GetForumInfo @a_intForumID int
as
declare @intTopicCount int
declare @intRootTopicCount int
set nocount on
if not exists(select * from Forum where id=@a_intForumID) return 0
select @intTopicCount = count(*) from bbs where forumid = @a_intForumID
select @intRootTopicCount = count(*) from bbs where forumID=@a_intForumID and fatherid=0
select * , 'TopicCount'=@intTopicCount , 'RootTopicCount' = @intRootTopicCount
from Forum where id = @a_intForumID
set nocount off
go
select id , rootid , title , fatherid from forum
/*************************************************************************/
/* */
/* procedure : up_GetPostedForumInfo */
/* */
/* Description: 取得指定版面精華區的相關信息 */
/* */
/* Parameters: @a_intForumID */
/* */
/* Use table: forum , bbs , bbsuser */
/* */
/* Author: bigeagle@163.net */
/* */
/* Date: 2000/4/17 */
/* */
/* History: */
/* */
/*************************************************************************/

if exists(select * from sysobjects where id = object_id('up_GetPostedForumInfo'))
drop proc up_GetPostedForumInfo
go

create proc up_GetPostedForumInfo @a_intForumID int
as
declare @intTopicCount int
declare @intRootTopicCount int
set nocount on
if not exists(select * from Forum where id=@a_intForumID) return 0
select @intTopicCount = count(*) from bbs where forumid = @a_intForumID and posted=1
select * , 'TopicCount'=@intTopicCount , 'RootTopicCount' = @intTopicCount
from Forum where id = @a_intForumID
set nocount off
go


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 和顺县| 湟源县| 仙桃市| 怀化市| 晋州市| 府谷县| 安化县| 绥芬河市| 华蓥市| 平潭县| 高台县| 襄垣县| 庆元县| 奉新县| 孟津县| 达孜县| 石城县| 霍山县| 新民市| 江达县| 宁德市| 彰化县| 德昌县| 邢台县| 乌拉特中旗| 炎陵县| 牟定县| 房山区| 天津市| 姜堰市| 当涂县| 乳源| 偏关县| 古浪县| 宁化县| 惠东县| 塔城市| 安新县| 安徽省| 行唐县| 万山特区|