BigEagle的数据库结构(转载,一动手,就轻拿5分)

80酷酷网    80kuku.com

  数据|数据库|数据库结构*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


/*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

/*************************************************************************/
/* */
/* procedure : up_GetTopicList */
/* */
/* Description: 贴子列表 */
/* */
/* Parameters: a_intForumID : 版面id */
/* a_intPageNo: 页号 */
/* a_intPageSize: 每页显示数,以根贴为准 */
/* */
/* Use table: bbs , forum */
/* */
/* Author: bigeagle163.net */
/* */
/* Date: 2000/2/14 */
/* */
/* History: */
/* */
/*************************************************************************/
if exists(select * from sysobjects where id = object_id('up_GetTopicList'))
drop proc up_GetTopicList
go

create proc up_GetTopicList
a_intForumID int ,
a_intPageNo int ,
a_intPageSize int
as
/*定义局部变量*/
declare intBeginID int
declare intEndID int
declare intRootRecordCount int
declare intPageCount int
declare intRowCount int
/*关闭计数*/
set nocount on

/*检测是否有这个版面*/
if not exists(select * from forum where id = a_intForumID)
return (-1)

/*求总共根贴数*/
select intRootRecordCount = count(*) from bbs where fatherid=0 and forumid=a_intForumID
if (intRootRecordCount = 0) --如果没有贴子,则返回零
return 0

/*判断页数是否正确*/
if (a_intPageNo - 1) * a_intPageSize > intRootRecordCount
return (-1)

/*求开始rootID*/
set intRowCount = (a_intPageNo - 1) * a_intPageSize + 1
/*限制条数*/
set rowcount intRowCount
select intBeginID = rootid from bbs where fatherid=0 and forumid=a_intForumID
order by id desc

/*结束rootID*/
set intRowCount = a_intPageNo * a_intPageSize
/*限制条数*/
set rowcount intRowCount
select intEndID = rootid from bbs where fatherid=0 and forumid=a_intForumID
order by id desc

/*恢复系统变量*/
set rowcount 0
set nocount off

select a.id , a.layer , a.forumid , a.subject , a.faceid , a.hits , a.time , a.UserID , a.fatherid , a.rootid ,
'Bytes' = datalength(a.content) , b.UserName , b.Email , b.HomePage , b.Signature , b.Point
from bbs as a join BBSUser as b on a.UserID = b.ID
where Forumid=a_intForumID and a.rootid between intEndID and intBeginID
order by a.rootid desc , a.ordernum desc
return(rowcount)
--select rowcount
go

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: