diff --git "a/14 \346\235\216\344\277\212\345\205\264/20230913 \345\214\273\351\231\242\347\256\241\347\220\206.md" "b/14 \346\235\216\344\277\212\345\205\264/20230913 \345\214\273\351\231\242\347\256\241\347\220\206.md" new file mode 100644 index 0000000000000000000000000000000000000000..e82f1c0a354391e75f6fa98c55ade39972db67e6 --- /dev/null +++ "b/14 \346\235\216\344\277\212\345\205\264/20230913 \345\214\273\351\231\242\347\256\241\347\220\206.md" @@ -0,0 +1,209 @@ +### 分析 + +1医生:医生编号、姓名 、 地址、 联系、科室、年龄 、职位 + +处方:处方号、病人年龄、处方内容、主治医师、病人姓名、病人性别 + +科室:科室编号 、 科室名称 + +护士:护士编号、姓名、联系电话、 + +患者:姓名、年龄、联系电话、性别、医保号、家庭住址、职业 + +检查项目:检查序号、检查工序、检验内容、检查结果、检查收费情况、检查医师 + +病例单: 病历号、病人姓名、病例内容、诊断时间、主治医师 + +收费项目:收费项目编号、项目类型、收费金额、收费人员、病人姓名 + +药品:药品编号、药品名称,药品介绍、分类 + +#### 概念模型 + +![image-20230914084659961](https://s2.loli.net/2023/09/14/PVUsy5CbW6OY8Bp.png) + +#### 逻辑模型 + +![](https://s2.loli.net/2023/09/14/KYc4sSX1Wp38V6w.png) + +### DDL语句 + +~~~mysql +/*==============================================================*/ +/* DBMS name: MySQL 5.0 */ +/* Created on: 2023/9/14 8:53:39 */ +/*==============================================================*/ + +CREATE DATABASE hospital CHARSET utf8; +use hospital; +drop table if exists detailed; + +drop table if exists doctor; + +drop table if exists dossier; + +drop table if exists medicine; + +drop table if exists nurse; + +drop table if exists patient; + +drop table if exists prescription; + +drop table if exists section; + +drop table if exists tariff; + +/*==============================================================*/ +/* Table: detailed */ +/*==============================================================*/ +create table detailed +( + detailed_id char(10) not null, + tariff_id char(11) not null, + pre_id char(10) not null, + detailed_deta char(10) not null, + primary key (detailed_id) +); + +/*==============================================================*/ +/* Table: doctor */ +/*==============================================================*/ +create table doctor +( + doctor_id char(10) not null, + doctor_name varchar(20) not null, + doctor_age int not null, + doctor_sex char(1) not null, + doctor_tel char(11) not null, + doctor_post varchar(10) not null, + doctor_address varchar(15), + primary key (doctor_id) +); + +/*==============================================================*/ +/* Table: dossier */ +/*==============================================================*/ +create table dossier +( + dossier_id char(12) not null, + doctor_id char(10) not null, + dossier_name varchar(8) not null, + dossier_content varchar(25) not null, + dossier_time varchar(15) not null, + dossier_doctor char(10) not null, + primary key (dossier_id) +); + +/*==============================================================*/ +/* Table: medicine */ +/*==============================================================*/ +create table medicine +( + medicine_id char(10) not null, + pre_id char(10) not null, + medicine_name char(10) not null, + medicine_type char(10) not null, + medicine_introduce char(10) not null, + primary key (medicine_id) +); + +/*==============================================================*/ +/* Table: nurse */ +/*==============================================================*/ +create table nurse +( + nurse_id char(10) not null, + section_id char(10) not null, + nurse_name char(10) not null, + nurse_tel char(10) not null, + primary key (nurse_id) +); + +/*==============================================================*/ +/* Table: patient */ +/*==============================================================*/ +create table patient +( + patient_id char(10) not null, + dossier_id char(12) not null, + patient_name varchar(10) not null, + patient_age int not null, + patient_sex char(1) not null, + patient_address varchar(12) not null, + patient_idnumber char(18) not null, + patient_post varchar(10), + primary key (patient_id) +); + +/*==============================================================*/ +/* Table: prescription */ +/*==============================================================*/ +create table prescription +( + pre_id char(10) not null, + doctor_id char(10) not null, + patient_id char(10) not null, + pra_content varchar(15) not null, + patient_name varchar(10) not null, + patient_sex char(1) not null, + patient_age int not null, + attending_doctor char(8) not null, + primary key (pre_id) +); + +/*==============================================================*/ +/* Table: section */ +/*==============================================================*/ +create table section +( + section_id char(10) not null, + doctor_id char(10), + section_name varchar(10) not null, + primary key (section_id) +); + +/*==============================================================*/ +/* Table: tariff */ +/*==============================================================*/ +create table tariff +( + tariff_id char(11) not null, + tariff_name varchar(5) not null, + tariff_project varchar(5) not null, + project_type varchar(10) not null, + tariff_money decimal(5,1) not null, + tariff_staff varchar(5) not null, + primary key (tariff_id) +); + +alter table detailed add constraint FK_detailed_tariff foreign key (tariff_id) + references tariff (tariff_id) on delete restrict on update restrict; + +alter table detailed add constraint FK_pay foreign key (pre_id) + references prescription (pre_id) on delete restrict on update restrict; + +alter table dossier add constraint FK_write foreign key (doctor_id) + references doctor (doctor_id) on delete restrict on update restrict; + +alter table medicine add constraint FK_reason foreign key (pre_id) + references prescription (pre_id) on delete restrict on update restrict; + +alter table nurse add constraint FK_section_nurse foreign key (section_id) + references section (section_id) on delete restrict on update restrict; + +alter table patient add constraint FK_pertain foreign key (dossier_id) + references dossier (dossier_id) on delete restrict on update restrict; + +alter table prescription add constraint FK_doctor_pre foreign key (doctor_id) + references doctor (doctor_id) on delete restrict on update restrict; + +alter table prescription add constraint FK_possess foreign key (patient_id) + references patient (patient_id) on delete restrict on update restrict; + +alter table section add constraint FK_doctor_section foreign key (doctor_id) + references doctor (doctor_id) on delete restrict on update restrict; + + +~~~ +