From e803e69945b134b42167c8cfd290c1781018628d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=A3=E7=91=9E?= <3462909738@qq.com> Date: Thu, 14 Sep 2023 12:41:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B9=9D=E6=9C=88=E5=8D=81=E5=9B=9B=E6=97=A5?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230914\344\275\234\344\270\232.md" | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 "44\344\273\243\347\221\236/20230914\344\275\234\344\270\232.md" diff --git "a/44\344\273\243\347\221\236/20230914\344\275\234\344\270\232.md" "b/44\344\273\243\347\221\236/20230914\344\275\234\344\270\232.md" new file mode 100644 index 0000000..80d5ddb --- /dev/null +++ "b/44\344\273\243\347\221\236/20230914\344\275\234\344\270\232.md" @@ -0,0 +1,106 @@ + + + + +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/13 22:58:34 */ +/*==============================================================*/ + + +drop table if exists department; + +drop table if exists diagnose; + +drop table if exists doctor; + +drop table if exists hospital; + +drop table if exists pharmacy; + +drop table if exists sick; + +/*==============================================================*/ +/* Table: department */ +/*==============================================================*/ +create table department +( + d_id varchar(11) not null, + hospital_name varchar(10), + d_name varchar(11) not null, + d_tel varchar(15) not null, + d_address varchar(25) not null, + primary key (d_id) +); + +/*==============================================================*/ +/* Table: diagnose */ +/*==============================================================*/ +create table diagnose +( + "doctor-ID" varchar(15) not null, + "sick-IDcar" varchar(15) not null, + "drug-id" varchar(15), + "prescription-id" varchar(15) not null, + primary key ("doctor-ID", "sick-IDcar") +); + +/*==============================================================*/ +/* Table: doctor */ +/*==============================================================*/ +create table doctor +( + "doctor-ID" varchar(15) not null, + d_id varchar(11), + "doctor-name" char(4) not null, + "doctor-tel" varchar(15) not null, + primary key ("doctor-ID") +); + +/*==============================================================*/ +/* Table: hospital */ +/*==============================================================*/ +create table hospital +( + hospital_name varchar(10) not null, + primary key (hospital_name) +); + +/*==============================================================*/ +/* Table: pharmacy */ +/*==============================================================*/ +create table pharmacy +( + "drug-id" varchar(15) not null, + "drug-name" varchar(12) not null, + primary key ("drug-id") +); + +/*==============================================================*/ +/* Table: sick */ +/*==============================================================*/ +create table sick +( + "sick-name" char(4) not null, + "sick-age" int not null, + "sick-sex" char(1) not null, + "sick-tel" varchar(15) not null, + "sick-IDcar" varchar(15) not null, + primary key ("sick-IDcar") +); + +alter table department add constraint FK_Relationship_1 foreign key (hospital_name) + references hospital (hospital_name) on delete restrict on update restrict; + +alter table diagnose add constraint FK_Relationship_4 foreign key ("doctor-ID") + references doctor ("doctor-ID") on delete restrict on update restrict; + +alter table diagnose add constraint FK_Relationship_5 foreign key ("sick-IDcar") + references sick ("sick-IDcar") on delete restrict on update restrict; + +alter table diagnose add constraint FK_Relationship_6 foreign key ("drug-id") + references pharmacy ("drug-id") on delete restrict on update restrict; + +alter table doctor add constraint FK_Relationship_2 foreign key (d_id) + references department (d_id) on delete restrict on update restrict; + -- Gitee