24章论坛管理系统代码

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

create database bbs;

use bbs;

create table user

(uid int primary key unique not null, username char(20) not null, userpassword char(20) not null,

usersex bit not null,

useremail char(20) not null, userbirthday date not null,

userclass int not null,

userstatement char(50) not null, userregdate timestamp not null,

userpoint int not null

);

create table admin

(adminid int primary key unique not null, adminname char(20) not null, adminpassword char(20) not null

);

create table section

(sid int primary key unique not null, sname char(40) not null, smasterid int not null,

sstatement char(100) not null, sclickcount int not null,

stopiccount int not null

);

create table topic

( tid int primary key unique not null, tsid int not null,

tuid int not null,

treplycount int not null,

temotion char(20) not null,

ttopic char(100) not null, tcontents char(100) not null,

ttime timestamp not null, tclickcount int not null,

ttopiccount timestamp not null

);

create table reply

(rid int primary key unique not null,

tid int not null,

uid int not null,

remotion varchar(20) not null,

rtopic varchar(100) not null,

rcontents varchar(100) null,

rtime timestamp not null,

rclickcount int not null

);

create index index_topic_title on topic(ttopic);

create index index_topic_time on topic(ttime);

alter table topic add index index_topic_contents(tcontents);

create index index_section_name on section(sname);

create index index_reply_rtime on reply(rtime);

create index index_reply_rtopic on reply(rtopic);

create index index_reply_rid on reply(rid);

create view topic_view as

select section.sid, section.sname, topic.ttopic, topic.tcontents, topic.ttime from section , topic

where section.sid= topic.tsid;

delimiter &&

create trigger section_count after update

on section for each row

begin

update section set stopiccount=stopiccount+1

where sid=new.sid;

end

&&

delimiter ;

delimiter &&

create trigger update_userID after update

on user for each row

begin

update reply set uID=NEW.uID;

end

&&

delimiter;

delimiter &&

create trigger delete_user after delete on user for each row

begin

delete from top where uid=old.uid; end

&&

delimiter ;

相关文档
最新文档