diff --git "a/11 \351\202\271\344\272\250\344\274\237/\345\214\273\351\231\242.md" "b/11 \351\202\271\344\272\250\344\274\237/\345\214\273\351\231\242.md" new file mode 100644 index 0000000000000000000000000000000000000000..03453fdd6fc286e5ed549a20ca505c0780aea2c6 --- /dev/null +++ "b/11 \351\202\271\344\272\250\344\274\237/\345\214\273\351\231\242.md" @@ -0,0 +1,157 @@ +## 医院 + + + +``` + +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/13 21:56:43 */ +/*==============================================================*/ + + +drop table if exists doctor; + +drop table if exists drug; + +drop table if exists hospital; + +drop table if exists pharmacy; + +drop table if exists subject; + +drop table if exists 拿药; + +drop table if exists 病人; + +drop table if exists 诊断; + +drop table if exists 诊断表; + +/*==============================================================*/ +/* Table: doctor */ +/*==============================================================*/ +create table doctor +( + ho_id int not null, + ho_name char(255) not null, + Attribute_9 char(10), + primary key (ho_id) +); + +/*==============================================================*/ +/* Table: drug */ +/*==============================================================*/ +create table drug +( + drug_names char(255) not null, + dug_id int not null, + phar_id int, + primary key (dug_id) +); + +/*==============================================================*/ +/* Table: hospital */ +/*==============================================================*/ +create table hospital +( + hos_name char(255) not null, + hos_id char(255) not null, + sub_id int not null, + primary key (hos_id) +); + +/*==============================================================*/ +/* Table: pharmacy */ +/*==============================================================*/ +create table pharmacy +( + phar_id int not null, + hos_id char(255) not null, + phar_name char(255) not null, + primary key (phar_id) +); + +/*==============================================================*/ +/* Table: subject */ +/*==============================================================*/ +create table subject +( + sub_id int not null, + ho_id int not null, + sub_name char(255) not null, + primary key (sub_id) +); + +/*==============================================================*/ +/* Table: 拿药 */ +/*==============================================================*/ +create table 拿药 +( + diagnostic_list int not null, + pat_id int not null, + primary key (diagnostic_list, pat_id) +); + +/*==============================================================*/ +/* Table: 病人 */ +/*==============================================================*/ +create table 病人 +( + pat_id int not null, + pat_name char(255) not null, + pat_sex char(10) not null, + primary key (pat_id) +); + +/*==============================================================*/ +/* Table: 诊断 */ +/*==============================================================*/ +create table 诊断 +( + pat_id int not null, + ho_id int not null, + primary key (pat_id, ho_id) +); + +/*==============================================================*/ +/* Table: 诊断表 */ +/*==============================================================*/ +create table 诊断表 +( + diagnostic_list int not null, + dug_id int not null, + "Diagnostic table_content" char(255) not null, + primary key (diagnostic_list) +); + +alter table drug add constraint FK_Relationship_5 foreign key (phar_id) + references pharmacy (phar_id) on delete restrict on update restrict; + +alter table hospital add constraint FK_Relationship_10 foreign key (sub_id) + references subject (sub_id) on delete restrict on update restrict; + +alter table pharmacy add constraint FK_Relationship_4 foreign key (hos_id) + references hospital (hos_id) on delete restrict on update restrict; + +alter table subject add constraint FK_Relationship_9 foreign key (ho_id) + references doctor (ho_id) on delete restrict on update restrict; + +alter table 拿药 add constraint FK_拿药 foreign key (diagnostic_list) + references 诊断表 (diagnostic_list) on delete restrict on update restrict; + +alter table 拿药 add constraint FK_拿药2 foreign key (pat_id) + references 病人 (pat_id) on delete restrict on update restrict; + +alter table 诊断 add constraint FK_诊断 foreign key (pat_id) + references 病人 (pat_id) on delete restrict on update restrict; + +alter table 诊断 add constraint FK_诊断2 foreign key (ho_id) + references doctor (ho_id) on delete restrict on update restrict; + +alter table 诊断表 add constraint FK_Relationship_7 foreign key (dug_id) + references drug (dug_id) on delete restrict on update restrict; + + + +``` \ No newline at end of file