【正文】
x=39。) drop table bbsReply create table bbsReply ( RID int identity(1,1) not null, RtID int not null,RuID int not null, Rface int,Rcontents varchar(50) not null,Rtime datetime,RclickCount int ) go為bbsReply(回帖)表各個(gè)字段添加約束 alter table bbsReply add constraint PK_RID primary key(RID) alter table bbsReply add constraint FK_RtID foreign key(RtID) references bbsTopic(TID) alter table bbsReply add constraint FK_RuID foreign key(RuID) references bbsUsers(UID) alter table bbsReply add constraint DF_Rcontents check(len(Rcontents) = 6) alter table bbsReply add constraint DF_Rtime default(getDate()) for Rtime 以上為創(chuàng)建bbsReply(回帖)表的內(nèi)容及各字段的約束觸發(fā)器設(shè)計(jì)1.bbsUsers表上的出發(fā)器觸發(fā)器設(shè)計(jì) :Tri_udelete 描述:當(dāng)一個(gè)用戶被管理員刪除,其發(fā)表的主帖和跟帖也要被刪除 代碼:Use bbsDBGoCreate trigger Tri_udeleteOn bbsUsers After deleteAs Delete from bbsTopic where TuID in (select UID from deleted) Delete from bbsReply where RuID in (select UID from deleted):Tri_uupdate 描述:當(dāng)用戶的積分增加的一定值后,對(duì)應(yīng)的用戶等級(jí)會(huì)發(fā)生變化。因?yàn)楸敬蝏bs論壇系統(tǒng)的數(shù)據(jù)量小,而且只作實(shí)驗(yàn)之用,所以我們只用把數(shù)據(jù)存儲(chǔ)在使用的電腦硬盤上,不用作更多的安排。試運(yùn)行結(jié)果: 四、課程設(shè)計(jì)結(jié)果與分析在課程設(shè)計(jì)中,我設(shè)計(jì)了BBS論壇管理系統(tǒng),其中包含了對(duì)論壇的成員的管理,各個(gè)主題版塊的管理,版塊的各個(gè)帖子的管理,論壇的信息安全管理等?! ?。1.bbsUsers表上的觸發(fā)器試運(yùn)行:Tri_udelete 描述:當(dāng)一個(gè)用戶被管理員刪除,其發(fā)表的主帖和跟帖也要被刪除試運(yùn)行結(jié)果::Tri_uupdate描述:當(dāng)用戶的積分增加的一定值后,對(duì)應(yīng)的用戶等級(jí)會(huì)發(fā)生變化。才能充分利用索引的作用避免因索引引起的負(fù)面作用。) drop table bbsTopic create table bbsTopic ( TID int identity(1,1) not null, TsID int not null, TuID int not null,TreplyCount int, Tface int, Ttopic varchar(50) not null, Tcontents varchar(50) not null,Ttime datetime, TclickCount int,Tstate int not null,TlastReply datetime ) go為bbsTopic(主貼表)表個(gè)字段添加約束 alter table bbsTopic add constraint PK_TID primary key(TID) alter table bbsTopic add constraint FK_TsID foreign key(TsID) references bbsSection (SID) alter table bbsTopic add constraint FK_TuID foreign key(TuID) references bbsUsers (UID) alter table bbsTopic add constraint DF_TreplyCount default(0) for TreplyCount alter table bbsTopic add constraint CK_Tcontents check(len(Tcontents) = 6) alter table bbsTopic add constraint DF_Ttime default(getDate()) for Ttime alter table bbsTopic add constraint DF_TclickC