diff --git "a/40 \346\227\266\345\255\246\345\256\211/\345\214\273\351\231\242.md" "b/40 \346\227\266\345\255\246\345\256\211/\345\214\273\351\231\242.md" new file mode 100644 index 0000000000000000000000000000000000000000..d0b9d5ae663ed2ce501a40b96122120b26345ec9 --- /dev/null +++ "b/40 \346\227\266\345\255\246\345\256\211/\345\214\273\351\231\242.md" @@ -0,0 +1,171 @@ +~~~mysql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/13 20:31:06 */ +/*==============================================================*/ +drop database if exists doctor; +create database if not exists doctor charset utf8; +use doctor; + +drop table if exists chu_fang; + +drop table if exists dep; + +drop table if exists doctor; + +drop table if exists fee_record; + +drop table if exists guahao; + +drop table if exists medicine; + +drop table if exists patient; + +drop table if exists registration_fee; + +drop table if exists yi_zhu; + +/*==============================================================*/ +/* Table: chu_fang */ +/*==============================================================*/ +create table chu_fang +( + chu_fang_No int not null auto_increment, + doctor_No char(10), + yao_pin_No int not null, + count int not null, + primary key (chu_fang_No) +); + +/*==============================================================*/ +/* Table: dep */ +/*==============================================================*/ +create table dep +( + dep_No int not null auto_increment, + dep_name varchar(10) not null, + dep_tel numeric(11,0) not null, + kezhang_No int not null, + primary key (dep_No) +); + +/*==============================================================*/ +/* Table: doctor */ +/*==============================================================*/ +create table doctor +( + doctor_No char(10) not null, + doctor_job2 varchar(10), + dep_No int, + dep_name varchar(10) not null, + dep_tel numeric(11,0) not null, + kezhang_No int not null, + doctor_job char(10) not null, + primary key (doctor_No) +); + +/*==============================================================*/ +/* Table: fee_record */ +/*==============================================================*/ +create table fee_record +( + record_No int not null auto_increment, + patient_No int, + patinent_No numeric(9,0) not null, + deal_fee decimal(9,2) not null, + record_time datetime not null, + primary key (record_No) +); + +/*==============================================================*/ +/* Table: guahao */ +/*==============================================================*/ +create table guahao +( + doctor_No char(10) not null, + patient_No int not null, + guahao_No char(10) not null, + primary key (doctor_No, patient_No, guahao_No) +); + +/*==============================================================*/ +/* Table: medicine */ +/*==============================================================*/ +create table medicine +( + medicine_No int not null auto_increment, + medicine_name char(10) not null, + medicine_type char(10) not null, + medicine_specification varchar(10) not null, + medicine_price decimal(9,2) not null, + medicine_repertory int not null, + primary key (medicine_No) +); + +/*==============================================================*/ +/* Table: patient */ +/*==============================================================*/ +create table patient +( + patient_No int not null auto_increment, + patient_name char(10) not null, + patient_gender char(1) not null, + patient_ID numeric(18,0) not null, + patient_tel numeric(11,0) not null, + patient_balance decimal(9,2) not null, + primary key (patient_No) +); + +/*==============================================================*/ +/* Table: registration_fee */ +/*==============================================================*/ +create table registration_fee +( + doctor_job2 varchar(10) not null, + registration_fee decimal(9,2) not null, + primary key (doctor_job2) +); + +/*==============================================================*/ +/* Table: yi_zhu */ +/*==============================================================*/ +create table yi_zhu +( + yi_zhu_No int not null auto_increment, + chu_fang_No int, + medicine_No int, + yao_pin_No int not null, + count int not null, + danciyongliang int not null, + pinci int not null, + geiyaofangfa varchar(10) not null, + doctor_No2 int not null, + chufang_No int not null, + primary key (yi_zhu_No) +); + +alter table chu_fang add constraint FK_kaichufang foreign key (doctor_No) + references doctor (doctor_No) on delete restrict on update restrict; + +alter table doctor add constraint FK_have2 foreign key (doctor_job2) + references registration_fee (doctor_job2) on delete restrict on update restrict; + +alter table doctor add constraint FK_pin_yonng foreign key (dep_No) + references dep (dep_No) on delete restrict on update restrict; + +alter table fee_record add constraint FK_have foreign key (patient_No) + references patient (patient_No) on delete restrict on update restrict; + +alter table guahao add constraint FK_Relationship_2 foreign key (doctor_No) + references doctor (doctor_No) on delete restrict on update restrict; + +alter table guahao add constraint FK_Relationship_3 foreign key (patient_No) + references patient (patient_No) on delete restrict on update restrict; + +alter table yi_zhu add constraint FK_kaiyao foreign key (medicine_No) + references medicine (medicine_No) on delete restrict on update restrict; + +alter table yi_zhu add constraint FK_shuyu foreign key (chu_fang_No) + references chu_fang (chu_fang_No) on delete restrict on update restrict; +~~~ +