机房管理系统数据库设计

上传人:壹****1 文档编号:508484760 上传时间:2023-06-20 格式:DOC 页数:12 大小:443KB
返回 下载 相关 举报
机房管理系统数据库设计_第1页
第1页 / 共12页
机房管理系统数据库设计_第2页
第2页 / 共12页
机房管理系统数据库设计_第3页
第3页 / 共12页
机房管理系统数据库设计_第4页
第4页 / 共12页
机房管理系统数据库设计_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《机房管理系统数据库设计》由会员分享,可在线阅读,更多相关《机房管理系统数据库设计(12页珍藏版)》请在金锄头文库上搜索。

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

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

3、ar(10)否否管理人computed计算机表)字段名数据类型能否为空是否为主键说明IPchar(20)否是计算机IP地址enosmalli nt否否编号rnoint否否机房号brandChar(20)能否品牌n oteVarchar(IOO)能否备注Student(学生表)字段名数据类型能否为空是否作为主键说明snoInt否是学号sn ameChar(10)否否姓名sexChar(2)台匕 冃匕否性别classChar(20)台匕 冃匕否行政班Usertable (用户表)字段名数据类型能否为空是否作为主键说明un ameChar(20)否是用户名snoint否否学号pwordChar(20

4、)否否密码moneymoney能否余额Prepaid(充值表)字段名数据类型能否为空是否作为主键说明un ameChar(20)否是用户名ptimedatetime否是充值时间pmoneysmallm oney否否金额transChar(10)否否收费人员Standard(收费标准表)字段名数据类型能否为空是否作为主键说明rnoint否是机房号stimeChar(20)否是时间段smoneysmallm oney否否金额/小时Record (上机过程登记表)字段名数据类型能否为空是否作为主键说明IPchar(20)否是计算机IP地址begi ntimedatetime否是上机时间snoInt否

5、否学号en dtimedatetime能否下机时间typeChar(15)否否上机类型statistik (机房费用统计表)字段名数据类型能否为空是否作为主键说明IPchar(20)否是计算机IP地址datesdatetime否是日期Snoint否否学号mon eyssmallm oney否否费用图一机房实体E-R图图二学生实体E-R图机房1选择、n学生7机器数目机房号管理人机房号编号品牌备注1n计算机属于1上机111属于用户用户名学号密码余额学号行政班姓名计算机ID三、逻辑设计1、表间关系图PfgpaJ*._ usertoble *2、关系模式 机房(机房号,机房名,机器数目,管理人) 学生

6、(学号,姓名,性别,行政班) 计算机(编号,机房号,品牌,备注) 用户(用户名,学号,密码,余额)四、数据库实现1创建数据库1、创建数据库create database roomon( name=room_data, filename=E:roomdataroom_data, size=5MB, maxsize=10MB, filegrowth=1MB)log on( name=room_log, filename=E:roomlogroom_log, size=5MB, maxsize=10MB, filegrowth=1MB)2、创建表2、room(机房表)的创建create table

7、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) null, note varchar(50) null)4、student( 学生表 ) 的创建 create t

8、able student(sno int not null primary key, sname char(10) not null, sex char(2) null, class char(20) not null6、User (用户表)的创建 create table usertable (uname char(20) not null primary key, sno int not null, pword char(20) not null, moneys money null,)7、prepaid( 充值表 ) 的创建 create table prepaid( uname cha

9、r(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, constraint c_primary primary key(rno,stim

10、e) )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(IP char(20) not null, dates datetime not null

11、, 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 computer on computer.IP=statistik.IP inner join room on room.rno=computer.rno where room.

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

13、to statistik values(001,getdate(),101,2.5) 查询插入记录学生的余额 select sno 学号 ,moneys 余额 from usertable where sno=20115080923. 创建触发器实现充值时自动修改该生余额1)代码 create trigger un_money on prepaid for insert as update usertable set moneys=moneys+(select pmoney from inserted) where uname=(select uname from inserted)2)数据测试select sno 学号 ,moneys 余额 from usertable where sno=2011508092goinsert into prepaid values(bbb,getdate(),5, 个 vga ) gosel

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 活动策划

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号