diff --git "a/58 \351\231\210\350\203\234\346\235\260/2023-09-14.md" "b/58 \351\231\210\350\203\234\346\235\260/2023-09-14.md" new file mode 100644 index 0000000000000000000000000000000000000000..46d56a0e0a1048683a84585fe09745b714404510 --- /dev/null +++ "b/58 \351\231\210\350\203\234\346\235\260/2023-09-14.md" @@ -0,0 +1,97 @@ +![屏幕截图 2023-09-14 122151](C:\Users\陈胜杰\Pictures\Screenshots\屏幕截图 2023-09-14 122151.png) + +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/14 12:22:08 */ +/*==============================================================*/ + +create database hospital character set utf8; +use hospital; +drop table if exists case; + +drop table if exists doctor; + +drop table if exists drug; + +drop table if exists prescription; + +drop table if exists sick; + +/*==============================================================*/ +/* Table: case */ +/*==============================================================*/ +create table case +( + case_id int not null auto_increment, + sick_id decimal, + doctor_id int, + case_pathogen varchar(200) not null, + therapy_method text not null, + primary key (case_id) +); + +/*==============================================================*/ +/* Table: doctor */ +/*==============================================================*/ +create table doctor +( + doctor_id int not null auto_increment, + doctor_name varchar(20) not null, + docyor_sex varchar(1) not null, + doctor_num varchar(11) not null, + primary key (doctor_id) +); + +/*==============================================================*/ +/* Table: drug */ +/*==============================================================*/ +create table drug +( + drug_id int not null auto_increment, + sick_id decimal, + drug_name varchar(50) not null, + drug_num int not null, + primary key (drug_id) +); + +/*==============================================================*/ +/* Table: prescription */ +/*==============================================================*/ +create table prescription +( + drug_id int not null, + doctor_id int not null, + primary key (drug_id, doctor_id) +); + +/*==============================================================*/ +/* Table: sick */ +/*==============================================================*/ +create table sick +( + sick_id decimal not null, + doctor_id int, + sick_name varchar(10) not null, + sick_sex varchar(1) not null, + sick_num varchar(11) not null, + sick_message text not null, + primary key (sick_id) +); + +alter table case add constraint FK_have foreign key (sick_id) + references sick (sick_id) on delete restrict on update restrict; + +alter table case add constraint FK_looks foreign key (doctor_id) + references doctor (doctor_id) on delete restrict on update restrict; + +alter table drug add constraint FK_get foreign key (sick_id) + references sick (sick_id) on delete restrict on update restrict; + +alter table prescription add constraint FK_prescription foreign key (drug_id) + references drug (drug_id) on delete restrict on update restrict; + +alter table prescription add constraint FK_prescription2 foreign key (doctor_id) + references doctor (doctor_id) on delete restrict on update restrict; + +alter table sick add constraint FK_look foreign key (doctor_id) + references doctor (doctor_id) on delete restrict on update restrict; \ No newline at end of file