67,513
社区成员
发帖
与我相关
我的任务
分享
drop table request;
drop table requesttype;
drop table requesttemplate;
drop table user;
drop table usertype;
--创建用户类型表
create table usertype
(
id int(5) primary key not null,
name varchar(10) not null
);
--创建用户表
create table user
(
id int(5) primary key not null,
username varchar(20) not null,
userpwd varchar(20) default 'abc123_',
email varchar(30),
roleid int(5) ,
reportmanagerid int(5),
foreign key(reportmanagerid) references user(id),
foreign key(roleid) references usertype(id)
);
--创建请求模板
create table requesttemplate
(
id int(5) primary key not null,
summary varchar(100) not null,
reason varchar(100) not null,
forwhomid int(5) not null,
preferredtime Date not null,
steps varchar(600) not null,
foreign key(forwhomid) references user(id)
);
commit;
--请求类型表
create table requesttype
(
id int(5) primary key not null,
name varchar(30) not null,
templateid int(5) not null,
engineervisible boolean ,
foreign key(templateid) references requesttemplate(id)
);
--创建请求表
create table request
(
id int(10) primary key not null,
requesterid int(5) not null,
requestdate date not null,
requesttypeid int(5) not null,
executorid int(5),
approveddate date,
title varchar(50) not null,
contentid int(5) not null,
status int(5),
foreign key(contentid) references requesttemplate(id),
foreign key(requesterid) references user(id),
foreign key(requesttypeid) references requesttype(id),
foreign key(executorid) references user(id)
);
commit;
--插入请求模板
insert into requesttemplate values(1,'do not limit the download',
'we all need software to update ourselves',
1,
'2011-11-17',
'1.release to the download for a short time;
2.watch out for the situation;
3.if there is no any problem we can go through it');
insert into requesttemplate values(2,'update the hardware',
'we all need best hardware to work better',
2,
'2011-11-20',
'1.update a part of computer;
2.watch out for the situation;
3.if there is no any problem we can go through it');
insert into requesttemplate values(3,'do not limit the website access',
'we all need more resources to work',
3,
'2011-11-23',
'1.release a part of the website access;
2.watch out for the situation;
3.if there is no any problem we can go through it');
commit;
--插入请求类型
insert into requesttype(id,name,templateid) values(1,'Software Download',1);
insert into requesttype(id,name,templateid) values(2,'Hardware Issue',2);
insert into requesttype(id,name,templateid) values(3,'Website Access',3);
commit;
--插入用户类型
insert into usertype values(1,'Engineer');
insert into usertype values(2,'ITManager');
insert into usertype values(3,'Admin');
insert into usertype values(4,'SDM');
insert into usertype values(5,'ITStaff');
commit;
--插入用户
insert into user(id,username,userpwd) values(1,'awl','123');
insert into user(id,username,userpwd) values(2,'irwin','1123');
insert into user(id,username,userpwd) values(3,'harris','123');
insert into user(id,username,userpwd) values(4,'好人','123');
commit;