版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、数据库课程设计 医院数据库设计,小组成员 2912601016 池泽生(组长): 主要负责触发器和存储过程 2912601015 黄仕嘉: 主要负责对创建好的数据库属性(包括断言)的增删改,兼做部分查询 2912601009 姜青余: 主要负责数据的查询 2912601023 佟晏美: 主要负责创建表 2912601029 李秦州: 主要负责数据的增,删,改,需求分析概要,人类进入21世纪,医院作为一个特殊的行业,其发展也与信息化的今天密切相关。 目前国家医院正处于改革阶段,需要对医疗市场的进一步规范与效率化提出新的改变。 这也要求了医院加强自身的管理与利用现代化工具对医院的整体信息资源进行整
2、合,将数据库运用于医院中,也肯定无疑的提高了工作的效率,信息的准确度,根除现行制度的弊端,达到减支增效的目的。有利于医院医疗水平与服务质量的提高,更好的造福人类,所以我们小组从医院数据库设计这方面,对医院主要的数据进行了设计与规划。,一、题目及其专题 题目:医院信息管理数据库设计 专题:医院信息管理的主要数据库设计与简单构想 二、课程设计来源及选题依据 设计来源:来自医院实际,以提供医院一个高效与合理的 数据库关系设计。 选题依据:提高医院的工作效率,与信息的管理自动化。确保医院数据库数据的合理性与有效、准确、完整性。 三、本设计所要达到的目的 从医院的总体部门,细化到各个医生与病人身上。提高
3、医院在对病人进行 诊断过程中,有关于医生、病人、诊断书、用药量与药价等等所产生信息 的整合与规划,保证其中信息的高效、准确、完整原则。,(草理版),医院管理数据字典:,医院管理数据字典:,医院管理数据字典:,医院管理数据字典:,Identity(1,1),电话编号,否,医院管理数据字典:,医院管理数据字典:,医院管理数据字典:,医院管理数据字典:,医院管理数据字典:,数据库关系图,(最终版),编制过程讲解:,1、创建数据库和表,create database Hospital;,use Hospital;,/创建数据库,/使用数据库,(在组长强行要求下,我组医院系统完全采用SQL语句完成!),
4、1、创建数据库和表,编制过程讲解:,Create Table Dept( DeptNo Char(10) primary key, Deptname char(20) not null, Deptparentno char(10) references Dept(DeptNo), Dno char(10) not null ),/创建部门表,create Table Doctor( Dno char(10) primary key, Dname char(20) not null, Dsex bit not null, Dborth datetime not null, DeptNo char
5、(10) references Dept(DeptNo), Dlevel char(20) not null, Dsalary Decimal(8,2) not null ),1、创建数据库和表,编制过程讲解:,/创建医生表,1、创建数据库和表,编制过程讲解:,create table Patient ( Pno char(10) primary key, Pname char(20) not null, Psex bit not null, Pborth DateTime not null, Paddress char(100) ),/创建病人表,1、创建数据库和表,编制过程讲解:,crea
6、te table P_phone ( PhoneNo int identity(1,1) primary key , Pcode char(20) not null, Pid char(10) references Patient(Pno) not null, Ptype char(10), ),/创建病人联系方式表,create table Medicine ( Mno char(10) primary key, Mname char(50) not null, Mtype char(10) not null, Munite char(10) not null, Mprice Decimal
7、(8,2) not null ),1、创建数据库和表,编制过程讲解:,/创建药品表,create table Diagnosis ( Dgno char(10) primary key, Pno char(10) references Patient(Pno), Dno char(10) references Doctor(Dno), Sympton char(500) not null, Diognosis char(100) not null, Dgtime Datetime not null, Dgfee Decimal(8,2) ),编制过程讲解:,1、创建数据库和表,/创建就诊表,1
8、、创建数据库和表,编制过程讲解:,create table RecipeMaster ( Rno int identity(1,1) primary key, Dgno char(10) references Diagnosis(Dgno) not null, Rtime Datetime not null ),/创建主治表,1、创建数据库和表,编制过程讲解:,create table recipedetail ( Rno int references RecipeMaster(Rno), Mno char(10) references Medicine(Mno), Mcount Decima
9、l(5,5) not null, primary key(Rno,Mno) ),/创建治疗细节表,1、创建数据库和表,编制过程讲解:,create table Fee ( Fno int identity(1,1) primary key, Rno int references RecipeMaster(Rno), Ftime Datetime not null, Fmoney decimal(8,2) not null ),/创建费用表,编制过程讲解:,2、对表进行的调整与修改,alter table Dept add foreign key (Dno) references Doctor(
10、Dno),/增加部门经理的外键,alter table Diagnosis add check(Dgfee=0),/添加费用的约束条件,alter table Fee add Ftime Datetime not null,alter table Fee drop column Ftime,/删除列,/添加新列,alter table Fee add check(Fmoney=0),alter table recipedetail alter column Mcount decimal(10,5) not null;,/修改列属性,编制过程讲解:,3、事务与触发器演示,create trigg
11、er trigger1 on Fee for insert as begin try begin transaction if (select Dgfee from Diagnosis where Dgno in ( select Dgno from RecipeMaster where RecipeMaster.Rno=(select Rno from inserted where Fno=identity) )0,本触发器功能为当费用表增加记录是,与其相对应的就诊表的费用属性也相应增加,(第一部分),update Diagnosis set Diagnosis.Dgfee=Diagnosi
12、s.Dgfee+(select Fmoney from inserted where Fno=identity) where Dgno in ( select Dgno from RecipeMaster where RecipeMaster.Rno=(select Rno from inserted where Fno=identity) ) else update Diagnosis set Diagnosis.Dgfee=(select Fmoney from inserted where Fno=identity) where Dgno in ( select Dgno from Re
13、cipeMaster where RecipeMaster.Rno=(select Rno from inserted where Fno=identity) ) commit end try,编制过程讲解:,3、事务与触发器演示,(第二部分),begin catch if(Trancount0) rollback declare errmsg nvarchar(4000), ErrSeverity int select errmsg=error_message(),ErrSeverity=error_severity() raiserror(errmsg,ErrSeverity,1) end
14、 catch,编制过程讲解:,3、事务与触发器演示,(第三部分),drop trigger trigger1,/删除触发器,编制过程讲解:,4、增删查改演示,Insert into Fee(Rno,Ftime,Fmoney) values(1,2010-6-8,1.5) Insert into Doctor(Dno,Dname,Dsex,Dborth,Dlevel,Dsalary) values (D000001,张三,1,1980-3-8,医师,6000.00); insert into Dept(DeptNo,Deptname,Dno) values (DP00001,主管部门,D0000
15、01); update Doctor set DeptNo=DP00001 where Dno=D000001; Insert into Doctor(Dno,Dname,Dsex,Dborth,Dlevel,Dsalary) values (D000002,李四,1,1980-3-8,医师,6000.00); Insert into Doctor(Dno,Dname,Dsex,Dborth,Dlevel,Dsalary) values (D000003,王五,0,1983-3-8,医师,6000.00); Insert into Doctor(Dno,Dname,Dsex,Dborth,Dl
16、evel,Dsalary) values (D000004,吴六,1,1985-3-8,医生,4000.00); insert into Dept(DeptNo,Deptname,Deptparentno,Dno) values (DP00002,财务部,DP00001,D000002); insert into Dept(DeptNo,Deptname,Deptparentno,Dno) values (DP00003,药物部,DP00001,D000003);,insert into Dept(DeptNo,Deptname,Deptparentno,Dno) values (DP0000
17、4,人力部,DP00001,D000004); update Doctor set DeptNo=DP00002 where Dno=D000002; update Doctor set DeptNo=DP00003 where Dno=D000003; update Doctor set DeptNo=DP00004 where Dno=D000004; update Doctor set Dlevel=医师,Dsalary=6000.00 where Dno=D000004; Insert into Doctor(Dno,Dname,Dsex,Dborth,Dlevel,Dsalary)
18、values (D000005,小张,1,1979-3-8,医师,6000.00); insert into Dept(DeptNo,Deptname,Deptparentno,Dno) values (DP00005,医务部,DP00001,D000005); update Doctor set DeptNo=DP00005 where Dno=D000005;,编制过程讲解:,4、增删查改演示,Insert into Doctor(Dno,Dname,Dsex,Dborth,DeptNo,Dlevel,Dsalary) values (D000006,小李,1,1985-3-8,DP000
19、05,医师,6000.00); Insert into Doctor(Dno,Dname,Dsex,Dborth,DeptNo,Dlevel,Dsalary) values (D000007,小王,0,1986-3-8,DP00005,医生,4000.00); insert into Patient(Pno,Pname,Psex,Pborth,Paddress) values (P00001,甲,1,1969-6-9,扬子街号); insert into P_phone(Pcode,Pid,Ptype) values (12345678901,P00001,手机); insert into D
20、iagnosis(Dgno,Pno,Dno,Sympton,Diognosis,Dgtime) values(DG00001,P00001,D000006,牙龈出血,口腔溃疡,2010-5-5); insert into Medicine(Mno,Mname,Mtype,Munite,Mprice) values(M00001,创可贴,otc,片,0.50); insert into RecipeMaster(Dgno,Rtime) values(DG00001,2010-5-5); insert into recipedetail(Rno,Mno,Mcount) values (1,M000
21、01,0.00001); delete from recipedetail where Rno=1 and Mno=M00001,编制过程讲解:,4、增删查改演示,编制过程讲解:,4、增删查改演示,insert into recipedetail(Rno,Mno,Mcount) values (1,M00001,3); insert into Fee(Rno,Ftime,Fmoney) values(1,2010-5-5,1.5); update Diagnosis set Dgfee=1.5 where Dgno=DG00001;,编制过程讲解:,5、存储过程,create procedur
22、e pro_d Deptname char(16) as select Dno,Dname from Doctor where DeptNo in (select DeptNo from Dept where Deptname = Deptname) go exec pro_d 医务部,/根据部门名查找部门成员信息的存储过程,alter procedure pro_d Deptname char(16) as select * from Doctor where DeptNo in (select DeptNo from Dept where Deptname = Deptname) go,编
23、制过程讲解:,5、存储过程,/修改上一页的存储过程,编制过程讲解:,5、存储过程,create procedure pro_pt Pname char(20) as select Patient.Pno,Pname,Ptype,Pcode from Patient,P_phone where Patient.Pno=P_phone.Pid and Patient.Pno in ( select Pno from Patient where Pname=Pname ) go exec pro_pt 甲,drop procedure pro_pt,/根据病人查找病人联想方式的存储过程,编制过程讲解
24、:,5、存储过程,create procedure pro_drrf Dgno char(10) as update Diagnosis set Dgfee= ( select sum(Fmoney) from Fee where Rno in ( select Rno from RecipeMaster where Dgno=Dgno ) ) where Dgno=Dgno go exec pro_drrf DG00001,/修改就诊表信息的存储过程,create procedure pro_redetail Rno int as select Rno,Medicine.Mno,Mname,
25、Mtype,Munite,Mprice,Mcount from recipedetail,Medicine where recipedetail.Mno=Medicine.Mno and Rno=Rno go exec pro_redetail 1,编制过程讲解:,5、存储过程,/查询用药详细信息的存储过程,编制过程讲解:,5、视图,create view dept_info as select Dept.DeptNo,Deptname,Deptparentno,Dname,Doctor.Dno from Doctor,Dept where Dept.Dno=Doctor.Dno select * from dept_info,/有关部门详细信息的视图,with MaxS(value) as (select Max(Dsalary) from Doctor) select dno,Dname,Dsa
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 深圳春茗会动画
- 某公司企业文化培训
- 技能综合及诊断复习指导心理咨询师
- 数学函数建模及应用
- 电工技术正弦交流电路
- 生物化学第七章糖类代谢糖的有氧氧化
- 建造师执业资格考试大纲
- 八年级物理浮力课件
- 毕业答辩学生标兵
- 生活与哲学第二单元课件
- 2026宜宾市属国有企业人力资源中心宜宾天原科创设计有限公司公开招聘考试备考题库及答案解析
- 老年髋部骨折诊疗与管理指南2026年版
- 2026年重庆丰都县社区工作者招聘考试【结构化面试题库+高分答题模板】(含考官评分要点)
- 统编版九年级上册 道德与法治 第二单元《进入新时代》单元检测试卷(含答案)
- 2026江西九江长途汽车运输集团有限公司劳动合同制员工招聘4人考试模拟试题及答案解析
- 2026福汽集团审计稽核部招聘2人考试模拟试题及答案解析
- 四上2-8《呵护我们的器官》教学课件
- 新生儿PICC置管与维护技术
- CSCO肾癌诊疗指南2026
- 八年级英语上学期期中押题卷(深圳专用)原卷版
- 2025四川简阳农商行社会招聘笔试历年典型考题及考点剖析附带答案详解
评论
0/150
提交评论