From e88ba50ce32ea9ee132b8f1d6927b135f4726d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B0=B8=E6=B7=B3?= <2678158018@qq.com> Date: Wed, 13 Sep 2023 21:50:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=AC=AC=E5=9B=9B=E6=AC=A1=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230913\344\275\234\344\270\232.md" | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 "18 \345\276\220\346\260\270\346\267\263/20230913\344\275\234\344\270\232.md" diff --git "a/18 \345\276\220\346\260\270\346\267\263/20230913\344\275\234\344\270\232.md" "b/18 \345\276\220\346\260\270\346\267\263/20230913\344\275\234\344\270\232.md" new file mode 100644 index 0000000..9e7cdd3 --- /dev/null +++ "b/18 \345\276\220\346\260\270\346\267\263/20230913\344\275\234\344\270\232.md" @@ -0,0 +1,118 @@ +```mysql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/13 21:29:20 */ +/*==============================================================*/ +create database hospital charset utf8; + +use hospital; + +drop table if exists DEPARTMENT; + +drop table if exists DISPENSARY; + +drop table if exists DOCTOR; + +drop table if exists PATIENT; + +drop table if exists PRESCRIPT; + +/*==============================================================*/ +/* Table: DEPARTMENT */ +/*==============================================================*/ +create table DEPARTMENT #科室 +( + DEPARTMENT_ID int not null auto_increment, + DEPARTMENT_NUMBER varchar(20) not null, + primary key (DEPARTMENT_ID) +); + +insert into department values (null,110); + +insert into department values (null,119); + +insert into department values (null,120); + +insert into department values (null,911); + +insert into department values (null,100086); + +insert into department values (null,12345); + +/*==============================================================*/ +/* Table: DISPENSARY */ +/*==============================================================*/ +create table DISPENSARY #取药 +( + DISPENSARY_ID int not null auto_increment, + DISPENSARY_NAME varchar(10) not null, + DISPENSARY_USAGE varchar(100) not null, + primary key (DISPENSARY_ID) +); + +insert into dispensary values (null,'吗丁啉','饭后吃'); + +/*==============================================================*/ +/* 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_GENDER char(1) not null, + primary key (DOCTOR_ID) +); + +insert into doctor values (1,1,'东方饭店',12,'男'); + +insert into doctor values (null,2,'西方饭店',21,'女'); + + +/*==============================================================*/ +/* Table: PATIENT */ +/*==============================================================*/ +create table PATIENT #病人 +( + PATIENT_ID int not null auto_increment, + DOCTOR_ID int, + PATIENT_NAME varchar(10) not null, + PATIENT_GENDER char(1) not null, + PATIENT_NUMBER varchar(20) not null, + primary key (PATIENT_ID) +); + +insert into patient values (null,1,'本地接送','男','12138'); + +insert into patient values (null,2,'外地接送','女','12333'); + +/*==============================================================*/ +/* Table: PRESCRIPT */ +/*==============================================================*/ +create table PRESCRIPT #药方 +( + DISPENSARY_ID int not null, + PATIENT_ID int not null, + primary key (DISPENSARY_ID, PATIENT_ID) +); + +insert into prescript values (1,1); + +insert into prescript values (2,2); + +alter table DOCTOR add constraint FK_SUBORDINATE foreign key (DEPARTMENT_ID) + references DEPARTMENT (DEPARTMENT_ID) on delete restrict on update restrict; + +alter table PATIENT add constraint FK_DIAGNOSE foreign key (DOCTOR_ID) + references DOCTOR (DOCTOR_ID) on delete restrict on update restrict; + +alter table PRESCRIPT add constraint FK_PRESCRIPT foreign key (DISPENSARY_ID) + references DISPENSARY (DISPENSARY_ID) on delete restrict on update restrict; + +alter table PRESCRIPT add constraint FK_PRESCRIPT2 foreign key (PATIENT_ID) + references PATIENT (PATIENT_ID) on delete restrict on update restrict; + + +``` + -- Gitee From c1d69932015cebc6605778caa9a4372f09b6799d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B0=B8=E6=B7=B3?= <2678158018@qq.com> Date: Wed, 13 Sep 2023 21:52:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=AC=AC=E4=BA=94=E6=AC=A1=E7=AC=94?= =?UTF-8?q?=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230913\347\254\224\350\256\260.md" | 1 + 1 file changed, 1 insertion(+) create mode 100644 "18 \345\276\220\346\260\270\346\267\263/20230913\347\254\224\350\256\260.md" diff --git "a/18 \345\276\220\346\260\270\346\267\263/20230913\347\254\224\350\256\260.md" "b/18 \345\276\220\346\260\270\346\267\263/20230913\347\254\224\350\256\260.md" new file mode 100644 index 0000000..4978f3e --- /dev/null +++ "b/18 \345\276\220\346\260\270\346\267\263/20230913\347\254\224\350\256\260.md" @@ -0,0 +1 @@ +若表内字段有多个值时,可将这个值单独取出新建一个表 \ No newline at end of file -- Gitee