diff --git "a/16 \351\230\231\350\213\217\346\226\207/20230913\345\214\273\351\231\242\347\263\273\347\273\237.md" "b/16 \351\230\231\350\213\217\346\226\207/20230913\345\214\273\351\231\242\347\263\273\347\273\237.md" new file mode 100644 index 0000000000000000000000000000000000000000..6860407bb69affb4019a5fa54b57c69ce1704206 --- /dev/null +++ "b/16 \351\230\231\350\213\217\346\226\207/20230913\345\214\273\351\231\242\347\263\273\347\273\237.md" @@ -0,0 +1,117 @@ +![屏幕截图 2023-09-13 234118](https://s2.loli.net/2023/09/13/D1eB7sqilIrubTZ.png) + + + +![屏幕截图 2023-09-13 234045](https://s2.loli.net/2023/09/13/GmKEMjQgX59BT4h.png) + + + +![屏幕截图 2023-09-13 234139](https://s2.loli.net/2023/09/13/T6UiduNM7sohSZg.png) + +```mysql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/13 23:37:23 */ +/*==============================================================*/ + +create database hospital charset utf8; +use hospital; + +drop table if exists department; + +drop table if exists doctor; + +drop table if exists drug; + +drop table if exists lookpatient; + +drop table if exists patient; + +drop table if exists patientEat; + +/*==============================================================*/ +/* Table: department */ +/*==============================================================*/ +create table department +( + doctor_id int not null, + department_id int not null auto_increment, + department_name varchar(10) not null, + department_tel int not null, + primary key (department_id) +); + +/*==============================================================*/ +/* Table: doctor */ +/*==============================================================*/ +create table doctor +( + doctor_id int not null auto_increment, + doctor_name varchar(10) not null, + doctor_age int not null, + doctor_sex char(1) not null, + primary key (doctor_id) +); + +/*==============================================================*/ +/* Table: drug */ +/*==============================================================*/ +create table drug +( + drug_id int not null auto_increment, + drug_name varchar(10) not null, + drug_price int not null, + drug_category varchar(10) not null, + primary key (drug_id) +); + +/*==============================================================*/ +/* Table: lookpatient */ +/*==============================================================*/ +create table lookpatient +( + doctor_id int not null, + patient_id int not null, + primary key (doctor_id, patient_id) +); + +/*==============================================================*/ +/* Table: patient */ +/*==============================================================*/ +create table patient +( + patient_id int not null auto_increment, + patient_name varchar(10) not null, + patient_age int not null, + patient_sex char(1) not null, + patient_sfz int not null, + patient_tel int not null, + primary key (patient_id) +); + +/*==============================================================*/ +/* Table: patientEat */ +/*==============================================================*/ +create table patientEat +( + drug_id int not null, + patient_id int not null, + primary key (drug_id, patient_id) +); + +alter table department add constraint FK_employ foreign key (doctor_id) + references doctor (doctor_id) on delete restrict on update restrict; + +alter table lookpatient add constraint FK_lookpatient foreign key (doctor_id) + references doctor (doctor_id) on delete restrict on update restrict; + +alter table lookpatient add constraint FK_lookpatient2 foreign key (patient_id) + references patient (patient_id) on delete restrict on update restrict; + +alter table patientEat add constraint FK_patientEat foreign key (drug_id) + references drug (drug_id) on delete restrict on update restrict; + +alter table patientEat add constraint FK_patientEat2 foreign key (patient_id) + references patient (patient_id) on delete restrict on update restrict; +``` +