create database dbFirstJBPM;
use dbFirstJBPM;
create table tb_user(
user_id MEDIUMINT NOT NULL AUTO_INCREMENT,
user_name VARCHAR(30),
user_password VARCHAR(30),
user_type int,
PRIMARY KEY (user_id)
);
create table tb_baoxiao(
baoxiao_id MEDIUMINT NOT NULL AUTO_INCREMENT,
baoxiao_title VARCHAR(30),
baoxiao_memo VARCHAR(30),
user_id MEDIUMINT,
baoxiao_data DATETIME,
baoxiao_flag int,
PRIMARY KEY (baoxiao_id)
);
create table tb_baoxiao_item(
item_id MEDIUMINT NOT NULL AUTO_INCREMENT,
item_name VARCHAR(30),
item_money VARCHAR(100),
item_memo VARCHAR(200),
baoxiao_id MEDIUMINT,
PRIMARY KEY (item_id)
);
create table tb_approve(
approve_id MEDIUMINT NOT NULL AUTO_INCREMENT,
user_id MEDIUMINT,
baoxiao_id MEDIUMINT,
approve_result VARCHAR(30),
approve_memo VARCHAR(30),
approve_date DATETIME,
PRIMARY KEY (approve_id)
);
alter table tb_baoxiao add index baoxiao_foreign_key (user_id),
add CONSTRAINT baoxiao_foreign_key
FOREIGN KEY (user_id)
REFERENCES tb_user(user_id);
alter table tb_baoxiao_item add index baoxiao_item_foreign_key (baoxiao_id),
add CONSTRAINT baoxiao_item_foreign_key
FOREIGN KEY (baoxiao_id)
REFERENCES tb_baoxiao(baoxiao_id);
alter table tb_approve add index approve_user_foreign_key (user_id),
add CONSTRAINT approve_user_foreign_key
FOREIGN KEY (user_id)
REFERENCES tb_user(user_id);
alter table tb_approve add index approve_baoxiao_foreign_key (baoxiao_id),
add CONSTRAINT approve_baoxiao_foreign_key
FOREIGN KEY (baoxiao_id)
REFERENCES tb_baoxiao(baoxiao_id);
insert into tb_user(user_name,user_password,user_type)
values('test','test',0),('manager','manager',1),('boss','boss',2);