机房管理系统数据库设计_第1页
机房管理系统数据库设计_第2页
机房管理系统数据库设计_第3页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、学院机房管理系统数据库设计说明书设计人:学号:班级:学院:目录一、需求分析1. 业务流程图2. 数据流图3. 数据字典二、概念设计1、实体属性图2、全局 E-R 图三、逻辑设计1、表间关系图2、关系模式四、数据库实现1、创建数据库2、创建表2、创建存储过程和触发器一、需求分析针对一般高校机房管理系统的需求分析、通过对学生上机过程、教学班上机过程、注册过程、充值过程、的内容的数据流程分析一现设计如下数据项和数据结构( 1)机房基本信息:包括机房号、机房名、计算机数目、管理人等( 2)计算机基本信息:包括计算机 IP 地址、编号、机房号、品牌、备注等( 3)学生基本信息:包括学号、姓名、性名、行政

2、班等( 4)用户基本信息:包括用户名、学号、密码、余额等1( 5)学生充值基本信息:包括用户名、充值时间、金额、办理人等( 6)机房收费标准基本信息:包括机房号、金额等(7)学生上机过程登记基本信息:包括计算机IP 地址、日期、上机时间、下机时间、学号、上机类型等(8)机房费用统计基本信息:包括计算机IP 地址、日期、统计时间、费用等1. 业务流程图2.数据流图23. 数据字典room( 机房表 )字段名数据类型能否为空是否为主键说明rnoint否是机房号rnamechar(10)否否机房名numbersmallint能否计算机数目managerchar(10)否否管理人computer( 计

3、算机表 )字段名数据类型能否为空是否为主键说明IPchar(20)否是计算机 IP 地址cnosmallint否否编号rnoint否否机房号brandChar(20)能否品牌noteVarchar(100)能否备注Student( 学生表 )字段名数据类型能否为空是否作为主键说明snoInt否是学号snameChar(10)否否姓名3sexChar(2)能否性别classChar(20)能否行政班Usertable (用户表)字段名数据类型能否为空是否作为主键说明unameChar(20)否是用户名snoint否否学号pwordChar(20)否否密码moneymoney能否余额Prepaid

4、( 充值表 )字段名数据类型能否为空是否作为主键说明unameChar(20)否是用户名ptimedatetime否是充值时间pmoneysmallmoney否否金额transChar(10)否否收费人员Standard( 收费标准表 )字段名数据类型能否为空是否作为主键说明rnoint否是机房号stimeChar(20)否是时间段smoneysmallmoney否否金额 /小时Record (上机过程登记表)字段名数据类型能否为空是否作为主键说明IPchar(20)否是计算机 IP 地址begintimedatetime否是上机时间snoInt否否学号endtimedatetime能否下机时

5、间typeChar(15)否否上机类型statistik (机房费用统计表 )字段名数据类型能否为空是否作为主键说明IPchar(20)否是计算机 IP 地址datesdatetime否是日期Snoint否否学号moneyssmallmoney否否费用4二、概念设计1、实体属性图机房学生机房号机房名管理人机器数目学号姓名性别行政班图一机房实体E-R 图图二学生实体E-R 图计算机计算机 ID编号机房号品牌备注2、全局 E-R 图5机房号机房名机器数目管理人1机房属于1选择上机1n1属于学生姓名性别学号行政班三、逻辑设计1 、表间关系图机房号编号品牌备注n计算机 ID计算机11用户用户名学号密码

6、余额62、关系模式机房(机房号,机房名,机器数目,管理人)学生(学号,姓名,性别,行政班)计算机(编号,机房号,品牌,备注)用户(用户名,学号,密码,余额)四、数据库实现1、创建数据库1、创建数据库create database room7on( name='room_data',filename='E:roomdataroom_data',size=5MB,maxsize=10MB,filegrowth=1MB)log on(name='room_log',filename='E:roomlogroom_log',size=5M

7、B,maxsize=10MB,filegrowth=1MB)2 、创建表2、 room( 机房表 )的创建create table room(rno int not null primary key,rname char(10) not null,number smallint null,manager char(10) not null)3、 computer(计算机表 )的创建create table computer(IP char(20) not null primary key,cno smallint not null ,rno int not null,brand char(20

8、) null,note varchar(50) null)4、 student( 学生表 ) 的创建create table student(sno int not null primary key,sname char(10) not null,sex char(2) null,class char(20) not null8)6、 User (用户表)的创建create table usertable(uname char(20) not null primary key,sno int not null,pword char(20) not null,moneys money null,

9、)7、 prepaid( 充值表 )的创建create table prepaid(uname char(20) not null,ptime datetime not null,pmoney smallmoney not null,trans char(10) not null,constraint p_primary primary key(uname,ptime)8、 standard( 收费标准表)的创建create table standard(rno int not null,stime char(20) not null,smoney smallmoney not null,co

10、nstraint c_primary primary key(rno,stime)11 、 record (上机过程登记表)的创建create table record(IP char(20) not null,sno int not null,begintime datetime not null,endtime datetime null,type char(15) not null,constraint t1 primary key(IP,begintime)12 、 statistik( 费用统计表) 的创建create table statistik(9IP char(20) not

11、 null,dates datetime not null,sno int not null,moneys smallmoney not null,constraint t2 primary key(IP,dates)2 、创建存储过程和触发器1、创建存储过程实现各机房上机费用的统计1)代码create proc s_room(rno int)asselect rname机房名,sum(moneys)费用from statistik inner join computeron computer.IP=statistik.IP inner join room on room.rno=comput

12、er.rnowhere room.rno=rnogroup by rname2、 创建触发器实现费用登记时,自动修改该生的账户余额。1)代码create trigger u_money on statistikfor insertasupdate usertableset moneys=moneys-(select moneys from inserted)where sno=(select sno from inserted)2)数据测试查询插入记录前学生的余额select sno学号,moneys余额from usertablewhere sno=2011508092执行插入操作inser

13、t into statistikvalues('001',getdate(),101,2.5)查询插入记录学生的余额select sno学号,moneys余额from usertablewhere sno=2011508092103.创建触发器实现充值时自动修改该生余额1)代码create trigger un_money on prepaidfor insertasupdate usertableset moneys=moneys+(select pmoney from inserted)where uname=(select uname from inserted)2)数据测试select

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论