From 31c17f0c7808e1708e1c9b0838250fda8405b250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E5=AD=90=E8=B1=AA?= <2936219414@qq.com> Date: Wed, 13 Sep 2023 21:49:49 +0800 Subject: [PATCH] zy --- .../9.13\344\275\234\344\270\232.md" | 106 ++++++++++++++++++ ...55\345\244\251\347\254\224\350\256\260.md" | 1 + 2 files changed, 107 insertions(+) create mode 100644 "54 \345\217\266\345\255\220\350\261\252/9.13\344\275\234\344\270\232.md" create mode 100644 "54 \345\217\266\345\255\220\350\261\252/\347\254\254\345\205\255\345\244\251\347\254\224\350\256\260.md" diff --git "a/54 \345\217\266\345\255\220\350\261\252/9.13\344\275\234\344\270\232.md" "b/54 \345\217\266\345\255\220\350\261\252/9.13\344\275\234\344\270\232.md" new file mode 100644 index 0000000..d733faf --- /dev/null +++ "b/54 \345\217\266\345\255\220\350\261\252/9.13\344\275\234\344\270\232.md" @@ -0,0 +1,106 @@ +```mysql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/13 21:45:21 */ +/*==============================================================*/ + + +drop table if exists department; + +drop table if exists doctor; + +drop table if exists drug; + +drop table if exists guahao; + +drop table if exists patient; + +drop table if exists warehouse; + +/*==============================================================*/ +/* Table: department */ +/*==============================================================*/ +create table department +( + department_id int not null auto_increment, + department_name varchar(20) not null, + department_address varchar(50) not null, + primary key (department_id) +); + +/*==============================================================*/ +/* Table: doctor */ +/*==============================================================*/ +create table doctor +( + doctor_id int not null auto_increment, + department_id int, + doctor_name varchar(10) not null, + doctor_age int not null, + doctor_sex varchar(10) not null, + illness varchar(20) not null, + primary key (doctor_id) +); + +/*==============================================================*/ +/* Table: drug */ +/*==============================================================*/ +create table drug +( + drug_id int not null auto_increment, + drug_name varchar(20) not null, + treatment varchar(50) not null, + primary key (drug_id) +); + +/*==============================================================*/ +/* Table: guahao */ +/*==============================================================*/ +create table guahao +( + patient_id int not null, + doctor_id int not null, + primary key (patient_id, doctor_id) +); + +/*==============================================================*/ +/* Table: patient */ +/*==============================================================*/ +create table patient +( + patient_id int not null auto_increment, + patient_name varchar(20) not null, + patient_age int not null, + patient_sex varchar(20) not null, + symptom varchar(100) not null, + primary key (patient_id) +); + +/*==============================================================*/ +/* Table: warehouse */ +/*==============================================================*/ +create table warehouse +( + drug_id int not null, + doctor_id int not null, + primary key (drug_id, doctor_id) +); + +alter table doctor add constraint FK_Relationship_3 foreign key (department_id) + references department (department_id) on delete restrict on update restrict; + +alter table guahao add constraint FK_guahao foreign key (patient_id) + references patient (patient_id) on delete restrict on update restrict; + +alter table guahao add constraint FK_guahao2 foreign key (doctor_id) + references doctor (doctor_id) on delete restrict on update restrict; + +alter table warehouse add constraint FK_warehouse foreign key (drug_id) + references drug (drug_id) on delete restrict on update restrict; + +alter table warehouse add constraint FK_warehouse2 foreign key (doctor_id) + references doctor (doctor_id) on delete restrict on update restrict; + + +``` + diff --git "a/54 \345\217\266\345\255\220\350\261\252/\347\254\254\345\205\255\345\244\251\347\254\224\350\256\260.md" "b/54 \345\217\266\345\255\220\350\261\252/\347\254\254\345\205\255\345\244\251\347\254\224\350\256\260.md" new file mode 100644 index 0000000..c474662 --- /dev/null +++ "b/54 \345\217\266\345\255\220\350\261\252/\347\254\254\345\205\255\345\244\251\347\254\224\350\256\260.md" @@ -0,0 +1 @@ +如果一个主体的属性有多个值那这个属性就可以拆成一个新的主体 \ No newline at end of file -- Gitee