From 3ce96497cb74372974a3001a7afda8f2a52f6139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E4=BA=A8=E8=80=80?= <2640788668@qq.com> Date: Thu, 14 Sep 2023 09:41:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E5=85=AD=E6=AC=A1=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../\345\214\273\351\231\242.markdown" | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 "21 \345\215\242\344\272\250\350\200\200/\345\214\273\351\231\242.markdown" diff --git "a/21 \345\215\242\344\272\250\350\200\200/\345\214\273\351\231\242.markdown" "b/21 \345\215\242\344\272\250\350\200\200/\345\214\273\351\231\242.markdown" new file mode 100644 index 0000000..3219d46 --- /dev/null +++ "b/21 \345\215\242\344\272\250\350\200\200/\345\214\273\351\231\242.markdown" @@ -0,0 +1,124 @@ +![](https://s2.loli.net/2023/09/14/Og46FvnekJRrqL8.png) + +--------------------------------- + +``` mysql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/13 23:04:41 */ +/*==============================================================*/ + +create database yy_db charset utf8; +use yy_db; +drop table if exists department; + +drop table if exists medicine; + +drop table if exists patients; + +drop table if exists registered; + +drop table if exists staff; + +drop table if exists treatmen_trecords; + +/*==============================================================*/ +/* Table: department */ +/*==============================================================*/ +create table department +( + department_id int not null auto_increment, + department_name varchar(10) not null, + department_directort varchar(10) not null, + primary key (department_id) +); + +/*==============================================================*/ +/* Table: medicine */ +/*==============================================================*/ +create table medicine +( + medicine_id int not null auto_increment, + medicine_name varchar(10) not null, + medicine_type varchar(10) not null, + medicine_price float(8,2) not null, + medicine_stock int not null, + primary key (medicine_id) +); + +/*==============================================================*/ +/* Table: patients */ +/*==============================================================*/ +create table patients +( + patients_id int not null auto_increment, + patients_name char(10) not null, + patients_gender char(1), + patients_age int not null, + patients_contact varchar(11), + primary key (patients_id) +); + +/*==============================================================*/ +/* Table: registered */ +/*==============================================================*/ +create table registered +( + registered_id int not null auto_increment, + patients_id int, + staff_id int, + registered_time datetime not null, + primary key ( registered_id) +); + + +/*==============================================================*/ +/* Table: staff */ +/*==============================================================*/ +create table staff +( + staff_id int not null auto_increment, + department_id int, + staff_name varchar(10) not null, + staff_gender char(1) not null, + staff_contact char(11) not null, + staff_speciality varchar(10), + primary key (staff_id) +); + +/*==============================================================*/ +/* Table: treatmen_trecords */ +/*==============================================================*/ +create table treatmen_trecords +( + treatmen_trecords_id int not null auto_increment, + staff_id int, + patients_id int, + medicine_id int, + treatmen_trecords_time datetime not null, + treatmen_trecords_diagnosis text not null, + treatmen_trecords_plan text not null, + primary key (treatmen_trecords_id) +); + +alter table registered add constraint FK_patients_registered foreign key (patients_id) + references patients (patients_id) on delete restrict on update restrict; + +alter table registered add constraint FK_staff_registered foreign key (staff_id) + references staff (staff_id) on delete restrict on update restrict; + +alter table staff add constraint FK_department_staff foreign key (department_id) + references department (department_id) on delete restrict on update restrict; + +alter table treatmen_trecords add constraint FK_patients_treatmen foreign key (patients_id) + references patients (patients_id) on delete restrict on update restrict; + +alter table treatmen_trecords add constraint FK_staff_treatmen foreign key (staff_id) + references staff (staff_id) on delete restrict on update restrict; + +alter table treatmen_trecords add constraint FK_take foreign key (medicine_id) + references medicine (medicine_id) on delete restrict on update restrict; + + +``` + -- Gitee