BIGEAGLE database structure (reprint, one hands, take 5 points lightly)

Source: Internet
Author: User
Tags count datetime define local getdate rowcount
Data | database | database STRUCTURE *BBS TABLE * *
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--root ID
Fatherid int default 0 NOT NULL,--Parent ID
Layer tinyint default 0 NOT NULL,--layer
Ordernum float default 0 NOT NULL,--Sort cardinality
UserID int default 0 NOT null--speaker ID
ForumID tinyint default 1 NOT NULL,--Layout ID
Subject varchar (255) Default ' NOT NULL '--theme
Content text default ' NOT null--contents
FaceID tinyint default 1 NOT null--expression
Hits int default 0 NOT null--number of clicks
IP varchar () default ' NOT NULL,--Post IP
Time datetime default GETDATE () is not NULL,--published
Posted bit default 0 NOT null--whether the essence posts
)
Go


/*forum Layout Form * *
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--root ID
Fatherid tinyint default 0 NOT NULL,--Parent ID
Layer tinyint default 0 NOT NULL,--layer
Title varchar default ' NOT NULL,--layout name
Description varchar (255) Default ' NOT NULL '--layout description
MasterID int default 1 NOT null--moderator ID
TopicCount int default 0 NOT null--total number of posts
DateTime default GETDATE () not NULL,--creation time
IsOpen bit default 0 NOT null-open
)
Go

/*************************************************************************/
/* */
* Procedure:up_gettopiclist * *
/* */
/* Description: List of posts * *
/* */
/* Parameters: @a_intForumID: Layout ID * *
/* @a_intPageNo: Page number * *
/* @a_intPageSize: Per-page display number, with the root paste as quasi * *
/* */
* * Use TABLE:BBS, forum * *
/* */
* Author:bigeagle@163.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
/* Define Local Variables * *
DECLARE @intBeginID int
DECLARE @intEndID int
DECLARE @intRootRecordCount int
DECLARE @intPageCount int
DECLARE @intRowCount int
/* Close Count * *
SET NOCOUNT ON

/* Detect if there is this page * *
If not EXISTS (SELECT * FROM forum where id = @a_intForumID)
Return (-1)

/* Ask for a total number of root paste * *
Select @intRootRecordCount = count (*) from BBS where fatherid=0 and forumid= @a_intForumID
if (@intRootRecordCount = 0)--returns zero if no posts
return 0

* To determine whether the number of pages is correct *
if (@a_intPageNo-1) * @a_intPageSize > @intRootRecordCount
Return (-1)

* * Ask to start rootid*/
Set @intRowCount = (@a_intPageNo-1) * @a_intPageSize + 1
/* Limit number of bars * *
SET ROWCOUNT @intRowCount
Select @intBeginID = Rootid from BBS where fatherid=0 and forumid= @a_intForumID
ORDER BY id DESC

/* End rootid*/
Set @intRowCount = @a_intPageNo * @a_intPageSize
/* Limit number of bars * *
SET ROWCOUNT @intRowCount
Select @intEndID = Rootid from BBS where fatherid=0 and forumid= @a_intForumID
ORDER BY id DESC

/* RESTORE SYSTEM Variable * *
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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.