You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
info_sys_114514/code/database/ddl.sql

91 lines
2.1 KiB

create table T_Drugs(
ID varchar(5),
name varchar(64),
num numeric(5,0),
primary key (ID));
create table T_Norms(
ID varchar(5),
feather varchar(10),
primary key (ID));
create table T_Vendor(
ID varchar(5),
name varchar(64),
address varchar(64),
phonenumber varchar(11),
monitor varchar(5),
zipcode varchar(6),
primary key (ID));
create table T_Request(
ID varchar(5),
num numeric(4,0),
req_date date,
primary key (ID));
create table T_User(
ID varchar(5),
name varchar(10),
sex char(1),
age numeric(2,0),
phonenumber varchar(11),
password varchar(20) not null,
role varchar(10) not null,
primary key (ID));
create table T_Department(
ID varchar(5),
name varchar(10),
member numeric(3,0),
floor varchar(2),
primary key (ID));
create table T_Type(
d_id varchar(5),
n_id varchar(5),
price numeric(5,2),
producer varchar(5),
primary key (d_id,n_id),
foreign key (d_id) references T_Drugs(ID),
foreign key (n_id) references T_Norms(ID),
foreign key (producer) references T_Vendor(ID));
create table T_Require(
d_id varchar(5),
r_id varchar(5),
primary key (d_id,r_id),
foreign key (d_id) references T_Drugs(ID),
foreign key (r_id) references T_Request(ID));
create table T_Commit(
r_id varchar(5),
u_id varchar(5),
primary key (r_id),
foreign key (r_id) references T_Request(ID),
foreign key (u_id) references T_User(ID));
create table T_Belong(
u_id varchar(5),
d_id varchar(5),
primary key (u_id),
foreign key (u_id) references T_User(ID),
foreign key (d_id) references T_Department(ID));
create table T_Sum_Commit(
r_id varchar(5),
d_id varchar(5),
primary key (r_id),
foreign key (r_id) references T_Request(ID),
foreign key (d_id) references T_Department(ID));