计算机科学与技术毕业论文_第1页
计算机科学与技术毕业论文_第2页
计算机科学与技术毕业论文_第3页
计算机科学与技术毕业论文_第4页
计算机科学与技术毕业论文_第5页
已阅读5页,还剩37页未读 继续免费阅读

下载本文档

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

文档简介

附件 1: 学 号: 2011131118 课 程 设 计 课程名 数据库系统概论 题 目 酒店管理系统 目 录 . 错误 !未定义书签。 引言 . - 2 - 一 .系统分析阶段 . - 4 - 1.1 系统分析阶段的目标 . - 4 - 1.2 基本信息要求 . - 11 - 1.3 基本处理要求 . - 11 - 1.4 输出显 示或者打印表格信息 . - 11 - 1.5 安全性和完整性要求 . - 12 - 二 .需求分析阶段 . - 4 - 2.1 业务流程图 . - 15 - 2.2 数据流图 . - 18 - 2.3 数据字典 . - 19 - 三概念设计阶段 . - 40 - 3.1 任务和目标 . - 15 - - 1 - 3.2 阶段结果 . - 18 - 四逻辑设计阶段 . - 40 - 4.1 数据库模式定义 . - 15 - 4.2 用户子模式定义 . - 18 - 五物理设计 . - 40 - 5.1 系统功能 . - 15 - 5.2 程序流程图 . - 18 - 5.3 实体、联系表 . - 15 - 5.4 用户子模式定义 . - 18 - 六实施阶段 . - 40 - 6.1 创建数据库 . - 15 - 6.2 建立数据表 . - 18 - 6.3 建立视图 . - 15 - 6.4 创建存储过程 . - 18 - 6.5 创建触发器 . - 15 - 6.6 插入具体数据 . - 18 - 七系统调试、测试 . - 40 - 7.1 基本表和视图查看 . - 15 - 7.2 检验部分存储过程 . - 18 - 7.3 检验部分触发器 . - 15 - 八心得体会 . - 40 - 九存在的问题与建议 . - 40 - 十参考文献 . - 40 - 附加 . - 40 - 1 存储过程汇总表 . - 15 - 2 触发器汇总表 . - 18 - - 2 - 引言 随着全球一体化使酒店管理业 更 加丰富多样化,市场更加广阔多渠道的同时,酒店管理业更面临着日趋激烈的竞争环境和不断攀升的客户期望,迫使业内人士不断进一步寻求扩大酒店客房销售,改进服务质量,降低管理成本和提升客户 满意度的新法宝来增强酒店管理业的核心竞争力。其中最有效的手段之一就是大规模应用先进的信息化技术,变革传统意义上的酒店客房竞争方式和经营管理模式以进而赢得新竞争优势。 本文以酒店客房管理系统为例,对客户的要求进行详细询问,调查酒店的组织机构,各部门的业务活动。并在上述活动后明确用户对系统的信息要求、处理要求、安全性及完整要求。明确系统边界 , 进行详尽的需求分析后,将系统划分为订房退订模块、入住模块、换房模块、退房模块、财务统计模块。按照数据库设计流程用业务流程图、数据流程图 、 数据字典详尽确切的表达客房管理的工作 流程。 通过 概念模型设计,逻辑模型设计,物理设计 , 实施阶段 , 系统调试、测试 ,建立一个能满足客房管理要求的方便实用的数据库系统。 - 3 - 一 .系统分析阶段 1.1 系统 分析阶段的目标 : 1.了解酒店客房管理的基本内容; 2.综合理解酒店客房管理各层管理人员的 不 同需求; 3.了解酒店客房管理的基本业务流程; 4.了解酒店客房人工管理模式与信息系统的工作概况,以及它们之间的区别; 5.通过调查和与酒店客房管理人员的交流,了解用户对酒店客房管理系统的业务要求 综合以上分析,创建一个比较优化的酒 店管理系统,可以实现对数据录入、存储、更新、查询等操作。 1.2 基本信息要求: 系统的处理对象是顾客的预订和退订信息管理、顾客的入住信息管理、顾客的换房信息管理、顾客的退房信息管理和财务统计信息管理。 系统的处理对象涉及以下几个方面的信息: 顾客基本信息( guest):顾客编号,顾客姓名,顾客性别,顾客身份证号,顾客电话,顾客地址,顾客预交款,顾客积分,顾客的折扣度,顾客余额。 客房基本信息( RoomInformation):客房编号,客房类型,客房价格,客房楼层,客房朝向。 消费项目基本信息( Yproject):消费项目编号,消费项目名称,消费项目价格。 客房物品基本信息( RoomObjectInformation):客房物品编号,客房物品名称,客房物品原价,客房物品赔偿倍数。 客房状态信息( RoomState):客房编号,顾客编号,入住时间,退房时间,预订入住时间,预订退房时间,入住价格,客房状态修改时间,标志位。 - 4 - 消费信息( Consumelist):顾客编号,消费项目编号,消费项目数量,消费时间。 物品损坏信息( ReturnObject):顾客编号,客房物品编号,客房编号,损坏个数,损坏时间。 1.3 基本处理要求: 1.能够存储一定数量的顾客信息,并方便有效的进行相应的顾客数据操作和管理,这主要包括: 1)顾客信息的录入,删除和修改。 2)顾客信息的关键字检索查询。 2.能够对顾客的预订退订信息,入住信息,换房信息,退房信息,消费信息和损坏物品信息进行相应的操作,这主要包括: 1)顾客预订退订,入住,换房,退房的登记,删除及修改(即对房态信息的登记,删除和修改)。 2)顾客消费信息的登记,删除及修改。 3)顾客损坏物品的登记,删除及修改。 4)顾客消费信息的汇总。 1.4 输出显示或者打印表格信息 对 于 查询 、 统计的结果能够列表显示。 1.5 安全性和完整性要求 能够提供一定的安全机制,提供数据信息授权访问,修改和删除,防止随意查询,修改及删除。具有可共享、冗余度小、数据独立性强、可拓展的特点。 二 .需求分析阶段 需求分析简单地说就是分析用户的要求。 也就 是 通过调查、收集与分析,获得用户对数据库的信息要求、处理要求、安全性与完整性要求。 2.1.业务流程图 ( 1)预订退订业务流程图 图 1.1 预订退订业务流程图 - 5 - ( 2)入住业务流程图 ( 3)退房业务流程图 ( 4)换房业务流程图 2.2.数据流图 ( 1) 顶层数据流图 图 1.2 入住业务流程图 图 1.3 退房业务流程图 图 1.4 换房业务流程图 - 6 - ( 2) 第一层数据流图 ( 3) 预订退订数据流 图 1.7 第一层数据流图 图 1.6 顶层数据流图 - 7 - ( 4)换房数据流图 图 1.8 预订退订数据流图 图 1.9 换房数据流图 - 8 - ( 5)入住数据流图 ( 6)财务统计数据流图 ( 7)退房数据流图 图 1.10 入住数据流图 图 1.11 财务统计数据流图 - 9 - 2.3.数据字典 数据字典是体统中各类数据描述的集合,是进行详细的数据手机和数九分析所获得的主要成果。数据字典 在数据库设计中占有很重要的地位。数据字典通常包括数据项、数据结构、数据流、数据存储、处理过程和外部实体 6 个部分。 数据项是不可再分的数据单位。 数据结构反映了数据之间的组合关系。 数据流是数据结构在系统内传输的路径。 数据存储是数据结构停留或保存的地方也是数据流的来源和去向之一。 处理过程具体处理逻辑一般用判定表或判定树来描述。 数据字典是需要描述处理过程 的 说明性信息。 ( 1) 数据项表 数据相编号 数据项名称 数据项别名 数据项类型 长度 取之范围 备注 Dl-1 Gno 顾客编号 Char 20 Dl-2 Gname 顾客姓名 Char 20 Dl-3 Gsex 顾客性别 Char 2 “女”,“男” Dl-4 Gid 顾客身份证号 Char 18 Dl-5 Gtel 顾客电话 Char 11 Dl-6 Gaddress 顾客地址 Char 20 图 1.12 退房数据流图 - 10 - 数据相编号 数据项名称 数据项别名 数据项类型 长度 取之范围 备注 Dl-7 Ggrade 顾客积分 int Dl-8 PreAccount 预交款 float Dl-9 grade 积分范围 int 大于等于 1 Dl-10 Discount 折扣 float 0.80,0.85,0.90,0.95 打折额度 Dl-11 Obno 客房物品编号 Char 20 Dl-12 Obname 客房物品名称 Char 20 Dl-13 Obprice 客房物品原价 float Dl-14 Obmultiple 赔偿倍数 float Dl-15 Yno 消费项目编号 Char 20 Dl-16 Yname 消费项目名称 Char 20 Dl-17 Yprice 消费项目单价 float Dl-18 Rno 客房编号 Char 20 Dl-19 Rtype 客房类型 Char 20 Dl-20 Rprice 客房单价 float Dl-21 Rfloor 客房楼层 Int Dl-22 Direction 客房朝向 Char 10 Dl-24 Atime 入住时间 datetime Dl-25 Rtime 预订时间 datetime Dl-26 Rltime 退房时间 datetime Dl-27 Intoprice 入住价格 float Dl-28 Stime1 预订房态修改时间 datetime Dl-29 Amoney 消费项目花费 float Dl-30 Dmoney 物品损坏费 float Dl-31 balance 余额 float Dl-32 Amount 消费项目个数 Int Dl-33 Dnum 损坏物品个数 Int Dl-34 Stime2 退订修改房态时间 datetime Dl-35 Stime3 入住修改房态时间 datetime Dl-36 Stime4 换房修改房态时间 datetime Dl-37 Stime5 退房修改房态时间 datetime - 11 - ( 2) 数据结构 数据结构编号 数据结构名 数据结构含义 数据结构组成 DS-1 guest 顾客信息 Gno,Gname,Gsex,Gid,Gtel,Gaddress,PreAccount,balance,grade,Discount DS-2 Into 入住信息 DS-1+DS-8 DS-3 reserve 预订信息 DS-1+DS-8 DS-4 return 退订信息 DS-1+DS-8 DS-5 RoomObjectInformation 客房物品信息 Obno,Obname,Obprice,Obmultiple DS-6 Yproject 娱乐价目表 Yno,Yname,Yprice DS-7 RoomInformation 客房信息 Rno,Rtype,Rprice,Floor,Direction DS-8 RoomState 房态信息 Rno,Atime,Rtime,Rltime,Ltime,Gno,Intoprice,Stime,days, flag DS-9 consum 消费清单 Cono,Gno,account,balance,Amoney,Dmoney,Cotime DS-10 Amuse 顾客消费单 DS-6+DS-1 DS-11 GoodsD 物品损坏单 DS-5+DS-1 三 .概念设计阶段 将需求分析得到的用户需求抽象为信息结构即概念模型 的过程就是概念结构设计。它是整个数据库设计的关键。 3.1 任务和目标 ( 1)选择底层数据流为切入点,通常选择实际系统中的子系统; ( 2)设计分 E-R 图,即各子模块的 E-R 图; ( 3)生成初步 E-R 图,通过合并方法,做到各子系统实体、属性、联系统一; ( 4)生成全局 E-R 图,通过消除冲突等方面。 在本酒店客房管理系统中,从第二层数据流程图下手,分析个第二层数据流程图和数据字典,知道整个系统的功能围绕“顾客”、“客房”和“消费”的处理。根据尸体与属性间的两条准则: 1 作为“属性”,不能再具有需要描述的性质。 2 “属性”不能与其他实体具有联系。 - 12 - 3.2 阶段结果 ( 1)根据不同的对象,从第二层数据流程图入手,分别画出各分 E-R 图: ( 2)从数据流图图 2.8、图 2.9、图 2.10 和图 2.11 抽象出的 E-R 图 : ( 3)从数据流图图 2.12 抽象出的 E-R 图: ( 4)从分 E-R 图图 3.1 和图 3.2 经消除冲突和冗余合成的总 E-R 图: 图 3.1 分 E-R 图 1 图 3.2 分 E-R 图 2 编号 名称 价格 索赔倍 数 朝向 楼层 价格 类型 编号 - 13 - 四 .逻辑设计阶段 概念设计阶段是独立于任何一种数据模型的,但是逻辑设计阶段就与选用的 DBMS 产品发生关系了,系统逻辑设计的任务就是将概念设计阶段设计好的基本 E-R 图转换为选用 DBMS 产品所支持的数据模型相符合的逻辑结构。具体内容包括数据组织(将 E-R 图转换成关系模型、模型优化、数据库模式定义、用户子模式设计)、数据处理(画出系统功能模块图)两大任务。 4.1 数据库模式定义: 数据库的模式定义包括三个方面: 1.数据的逻辑结构 ; 2.数据之间的联系; 3.数据有关的完整性约 束、安全性要求。 由于顾客与客房的联系方式为 1: n(一对多 ),可以将其之间的联系与 n 端实体客房合并,也可以独立作为一种关系模式,我们选择将其作为独立的关系模式。由于顾客与客房物品,消费项目的联系方式为 n:n(多对多 ),可以将其之间的联系转化为独立的关系模式,具体的基本 E-R 图向关系 - 14 - 模型的转化如下: 表 4 1 数据库模式汇总 编号 数据库模式 说明 T-1 guest 顾客基本信息 T-2 RoomInformation 客房基本信息 T-3 Yproject 消费项目基本信息 T-4 RoomObjectInformation 客房物品基本信息 T-5 RoomState 房态基本信息 T-6 Consumelist 消费基本信息 T-7 ReturnObject 物品赔偿信息 实体表: 顾客: guest(Gno,Gname,Gsex,Gid,Gtel,Gaddress,PreAccount,Ggrade ,Discount, balance) 客房基本信息: RoomInformation(Rno,Rtype,Rprice,Rfloor,Direction) 消费项目: Yproject( Yno,Yname,Yprice) 客房物品信息: RoomObjectInformation(Obno,Obname,Obprice,Obmultiple) 联系 表: 预订: Reserve(Gno,Rno,Stime1,Rtime, Rltime) 退订: Back(Gno,Rno,Stime2) 入住: Into(Gno,Rno,Stime3,Rtime,Rlime) 换房: Change(Gno,Rno,Stime4) 退房: Return(Gno,Rno,Stime5) 消费: Consumelist(Yno,Gno,Amount,Begintime) 物品赔偿单 Returnobject(Obno,Gno,Rno, Dtime ,Dnum) (注:画线的为主码 ) 4.2 用户子模式定义 将概念模型转换为全局逻辑模型后,还应该根据局部应用的需要,结合具体 DBMS 的特点,设计用户的外模式。用户模式注重考虑用户的习惯与方便。包括: 1.使用更符合用户习惯的别名。 2.可以对不同级别的用户定义不同的 View,以保证系统的安全性。 3.简化用户对系统 的使用。 表 4 2 用户子模式定义 编号 用户子模式( View)作用(共性:提供数据保密和安全保护机制 V-1 BookView 便于查询预定信息 V-2 IntoView 便于查询入住信息 V-3 EmRoView 便于查询空房信息 - 15 - 五 .物理设计 数据库的物理设计就是为逻辑数据模型选取一个最合适应用要求的物理结构的过程,在这个阶段中要完成两大任务: ( 1)确定数据库的物理结构,在关系数据库中主要是存取方法和存储结构; ( 2)对物理结构进行评价,评价的重点是时间和空间效率。 5.1 本系统的 功能主要包括如图几个方面: 5.2 程序流程图 管理信息系统处理方式的合理选择,是一个处理过程的设计问题。选择处理方式实际上就是根据系统的任务、目标和环境条件,合理选择信息活动的形式及其具体方法。 ( 1) 顾客基本信息的查询和更新:描述顾客信息的查询和更新(插入、删除和更新)的过程。 图 5.1 酒店管理系统功能模块图 酒店 - 16 - ( 2)客房物品、娱乐信息查询和更新(插入,删除和更新)程序流程图: 5.3 关于 E-R 图所需实体及其联系需要的表设计如下: 表 5 1 顾客基本信息 列名 数据类型 可否为空 说明 Gno char(20) not null 顾客编号 Gname char(20) not null 顾客姓名 Gsex char(2) not null 顾客性别 Gid char(18) not null 顾客身份证 Gtel char(11) 顾客电话 Gaddress char(20) 顾客地址 PreAccount float 顾客预付金额 Grade int 顾客积分 Discount float not null 顾客的折扣率 balance float 顾客余额 图 5.3 客房物品、娱乐信息查询和更新程序流程图 - 17 - 表 5 2 房间基本信息 列名 数据类型 可否为空 说明 Rno char(10) not null 房间编号 Rtype char(20) not null 房间类型 Rprice float not null 房间价格 Rfloor smallint not null 房间楼层 Direction char(10) not null 房间朝向 表 5 3 房间物品信息 列名 数据类型 可否为空 说明 Obno char(20) not null 物品编号 Obname char(20) not null 物品名字 Obprice float not null 物品价格 Obmultiple float not null 物品索赔倍数 表 5 4 房态信息 列名 数据类型 可否为空 说明 Rno char(10) not null 房间号 Gno char(20) not null 顾客号 Atime datetime 实际入住时间 Ltime datetime 实际退房时间 Rtime datetime 预订入住时间 Rltime datetime 预订退房时间 IntoPrice float 入住价格 days int 入住天数 Stime datetime 修改记录时间 flag char(1) 预订入住标志位 表 5 5 娱乐项目信息 列名 数据类型 可否为空 说明 Yno char(20) not null 娱乐项目编号 Yname char(20) not null 娱乐项目名称 Yprice float not null 娱乐项目单价(时间计费或个数计费) 表 5 6 娱乐消费信息 - 18 - 列名 数据类型 可否为空 说明 Gno char(20) not null 顾客号 Yno char(20) not null 商品号 Amount float 消费数量 Begintime datetime not null 消费开始时间 表 5 7 物品赔偿信息 列名 数据类型 可否为空 说明 Gno char(20) not null 顾客号 Rno char(10) not null 房间号 Obno char(20) not null 物品号 Dnum int 损坏个数 Dtime datetime Datetime 损坏时间 5.4 用户子模式定义 表 5 8 订房视图 列名 数据类型 可否为空 说明 Gno char(20) not null 顾客号 Rno char(10) not null 房间号 Rtype char(20) not null 房间类型 Rfloor smallint not null 房间楼层 Direction char(10) not null 房间朝向 IntoPrice float not null 入住价格 Rtime datetime not null 入住时间 Rltime datetime not null 打算退房时间 days int not null 居住天数 Begintime datetime not null 查看时时间 表 5 9 入住视图 列名 数据类型 可否为空 说明 Gno char(20) not null 顾客号 Gname char(20) not null 顾客姓名 Rno char(10) not null 房间号 Rtype char(20) not null 房间类型 Rfloor smallint not null 房间楼层 Direction char(10) not null 房间朝向 IntoPrice float not null 入住价格 Atime datetime not null 入住时间 - 19 - Ltime datetime not null 退房时间 days int not null 入住天数 PreAccount float not null 预付金额 Begintime datetime not null 查看时时间 表 5 10 空房视图 列名 数据类型 可否为空 说明 Rno char(10) not null 房间号 Rtype char(20) not null 房间类型 Rprice float not null 入住价格 Rfloor int not null 房间楼层 Direction char(10) not null 房间朝向 六实施阶段 6.1 创建数据库 CREATE DATABASE OrderDB1 ON (NAME=OrderDB, FILENAME=D:mySQLOrderDB1.mdf, SIZE=3, MAXSIZE=10, FILEGROWTH=1) LOG ON (NAME=OrderDBlog, FILENAME=D:mySQLOrderDB1log.ldf, SIZE=1, MAXSIZE=5, FILEGROWTH=1) 6.2 建立数据表 ( 1)顾客信息表创建: create table guest( Gno char(20) not null primary key, Gname char(8) not null, Gsex char(2) not null, Gid char(20) not null, Gtel char(11) not null, Gaddress char(20) null, PreAccount numeric(8,2) not null, - 20 - Grade int, Discount float, balance float, check (PreAccount=0.0 and Grade0) ) ( 2)客房信息表创建: create table RoomInformation( Rno char(10) not null primary key, Rtype char(20) not null, Rprice float not null, Rfloor smallint not null, Direction char(10) not null, check (Rfloor between 1 and 100), check (Direction in(正北 ,正南 ,正西 ,正东 ,东北 ,西南 ,西北 ,东南 ), check (Rtype in(标准 1,标准 2,豪华 1,豪华 2,高级 1,高级 2) ) ( 3)房态表创建: create table RoomState( Rno char(10) not null, Gno char(20) not null, Atime datetime, Ltime datetime, Rtime datetime, Rltime datetime, Intoprice float, days int, Stime datetime, flag char(1), primary key(Rno,Gno), foreign key(Rno)references RoomInformation(Rno), foreign key(Gno)references guest(Gno), check (flag in(1,2,3) ) ( 4)娱乐项目基本信息表创建: create table Yproject( Yno char(20) not null primary key, Yname char(20) not null, Yprice float not null, check(Yprice0.0) ) - 21 - ( 5)顾客娱乐消费信息表创建: create table ConsumeList( Gno char(20) not null, Yno char(20) not null, Amount float, Begintime datetime not null, primary key(Gno,Yno), foreign key(Gno)references guest(Gno), foreign key(Yno)references Yproject(Yno) ) ( 6)客房物品基本信息表创建: create table RoomObjectInformation( Obno char(20) not null primary key, Obname char(20) not null, Obprice float not null, Obmultiple float not null, ) ( 7)顾客赔偿物品基本信息表创建: create table ReturnObject( Gno char(20) not null, Rno char(10) not null, Obno char(20) not null, Dnum int, Dtime datetime not null, primary key(Gno,Rno,Obno), foreign key(Gno)references guest(Gno), foreign key(Rno)references RoomInformation(Rno), foreign key(Obno)references RoomObjectInformation(Obno) ) 6.3建立视图 ( 1)用于查询预订房信息的视图定义如下: create view BookView(Gno,Gname,Rno,Rtype,Rfloor,Direction,IntoPrice,Rtime,Rltime,Days,Stime) as select RoomState.Gno,Gname,RoomState.Rno,Rtype,Rfloor,Direction,IntoPrice,Rtime,Rltime,Days,Stime from RoomInformation,RoomState,guest where flag=1and RoomInformation.Rno=RoomState.Rno and RoomState.Gno=guest.Gno - 22 - ( 2)用于查询已入住房的试图如下: create view IntoView(Gno,Gname,Rno,Rtype,Rfloor,Direction,IntoPrice,Atime,Ltime,Days,Preaccount) as select RoomState.Gno,Gname,RoomState.Rno,Rtype,Rfloor,Direction,IntoPrice,Atime,Ltime,Days,Preaccount from RoomInformation,RoomState,guest where flag=2 and RoomInformation.Rno=RoomState.Rno and RoomState.Gno=guest.Gno (3)用于查询空房的视图定义如下: create view EmptyRoomView(Rno,Rtype,Rprice,Rfloor,Direction) as select Rno,Rtype,Rprice,Rfloor,Direction from RoomInformation where Rno not in (select Rno from Roomstate) 6.4 创建存储过程 ( 1) lsqSearchDate 的定义 : create procedure IsqSearchDate date datetime as select Yno,sum(Am ount) from ConsumeList where Begintime=date group by Yno ( 2) lsqSearchEmpty 的定义 : create procedure IsqSearchEmpty floor int as select Rno,Rtype,Rprice,Rfloor,Direction from EmptyRoomView where Rfloor=floor - 23 - ( 3) lsqWatchGuest 的定义 : create procedure IsqWatchGuest as select Gno,Gname,Gsex,Gid from guest ( 4) lsqSearchGuest 的定义 : create procedure IsqSearchGuest Gno char(20) as begin select Gno,Gname,Preaccount,balance from guest where Gno=Gno select RoomState.Rno,Rtype,IntoPrice from RoomState,RoomInformation where RoomState.Rno=Gno and RoomState.Rno=RoomInformation.Rno select c.Yno,Yname,Account,Account*Yprice AmuMoney,begintime from ComsumeList c,Yproject a where c.Gno=Gno and c.Yno=a.Yno select g.Rno,r.Obname,g.Dnum,r.Obprice,Obmultiple,Obprice * g.Dnum * r.Obmultiple AmendMoney,g.Dtime from ReturnObject g,RoomObjectInfomation r where g.Gno=Gno and g.Obno=r.Obno end ( 5) lsqConsumeList 的定义 : create procedure IsqConsumeList ConsumeList_Gno char(20), ConsumeList_Yno char(20), ConsumeList_Amount float, ConsumeList_Begintime datetime as insert into ConsumeList values(ConsumeList_Gno,ConsumeList_Yno,ConsumeList_Amount,ConsumeList_Begintime) ( 6) lsqAddRoomGoods 的定义 create procedure IsqAddRoomGoods GDnumber char(20), - 24 - GDname char(20), GDprice float, GDmultiple float as insert into RoomObjectInfomation(Obno,Obname,Obprice,Obmultiple) values(GDnumber,GDname,GDprice,GDmultiple) ( 7) lsqAddAmusement 的定义 : create procedure IsqAmusement Yno char(20), Yname char(20), Yprice float as insert into Yproject values(Yno,Yname,Yprice) ( 8) lsqAddGuest 的定义 : create procedure IsqAddGuest Gno char(20), Gname char(8), Gsex char(2), Gid char(20), Discount float as insert into guest(Gno,Gname,Gsex,Gid,Discount) values(Gno,Gname,Gsex,Gid,Discount) ( 9) lsqMoney 的定义 : create procedure IsqMoney Gno char(20), PreAccount float as update guest set PreAccount=PreAccount where Gno=Gno ( 10) lsqBook 的定义 : create procedure IsqBook Rno char(10), Gno char(20), Rtime datetime, - 25 - Rltime datetime, days int, Stime datetime, Discount float output, Rprice float output as begin select Discount=Discount from guest where Gno=Gno select Rprice=Rprice from RoomInformation where Rno=Rno insert into RoomState(Rno,Gno,Rtime,Rltime,IntoPrice,days,Stime,flag) values(Rno,Gno,Rtime,Rltime,Discount*Rprice,days,Stime,1) end ( 11) lsqInto 的定义 : create procedure IsqInto Rno char(10), Gno char(20), Atime datetime, Ltime datetime, days int, Stime datetime, money float as begin update guest set PreAccount=money update RoomState set Atime=Atime,Ltime=Ltime,days=days,Stime=Stime,flag=2 where Rno=Rno and Gno=Gno end ( 12) IsqInsertAmends 的定义 : create procedure IsqInsertAmends Gno char(20), Rno char(10), Obno char(20), Dnum int, Dtime datetime as insert into ReturnObject(Gno,Rno,Obno,Dnum,Dtime) - 26 - values(Gno,Rno,Obno,Dnum,Dtime) ( 13) lsqDeleteRoom 的定义 : create procedure IsqDeleteRoom Rno char(10), Gno char(20) as delete from RoomState where Rno=Rno and Gno=Gno 6.5 创建触发器 ( 1) 当插入订房信息(即插入房态信息),触发 guest 表,根据顾客积分计算顾客新的折扣度: create trigger tri_Discount on RoomState for insert as declare Grade int, Gno char(20) select Gno=Gno from inserted select Grade=Grade from guest where Gno=Gno if(Grade=0 and Grade300) begin update guest set Discount=1.00 where Gno=Gno end else if(Grade500) begin update guest set Discount=0.95 where Gno=Gno end else if(Grade700) begin update guest set Discount=0.90 where Gno=Gno end else if(Grade1000) - 27 - begin update guest set Discount=0.85 where Gno=Gno end else begin update guest set Discount=0.80 where Gno=Gno end ( 2)当修改房态信息(即插入入住信息)时,触发 guest 表,计算新积分及余额: create trigger tri_grade_balance on RoomState for update as begin declare IntoPrice float, days int select IntoPrice=IntoPrice from RoomState where Rno in(select Rno from inserted) and Gno in(select Gno from inserted) select days=days from RoomState where Rno in(select Rno from inserted) and Gno in(select Gno from inserted) update guest set balance=PreAccount-IntoPrice*days,grade=grade+IntoPrice*days where Gno in(select Gno from inserted) end ( 3)当修改房态信息(即插入入住信息)时,触发 guest 表,计算新积分及余额: create trigger tri_delete on RoomState for delete as begin update guest set PreAccount=0,balance=0 where Gno in(select Gno from deleted) end ( 4)删除客房信息(即退房)时,触发 guest 表,把顾客的预付款和余额设为 0: create trigger tri_grade on ConsumeList for insert - 28 - as begin declare Gno char(20), Yno char(20), Amount int, Yprice float select Gno=Gno,Yno=Yno,Amount=Amount from inserted select Yprice=Yprice from Yproject where Yno=Yno update guest set grade=grade+Yprice*Amount/10,balance=balance-Yprice*Amount where Gno=Gno end ( 5) .当插入新的物品赔偿信息时,触发孤儿 guest 表,从新计算顾客积分和余额: create trigger tri_AmendsMoney on ReturnObject for insert as begin declare Gno char(20), Obno char(20), Dnum int, Obprice float, Obmultiple float select Gno=Gno,Obno=Obno,Dnum=Dnum from inserted select Obprice=Obprice,Obmultiple=Obmultiple from RoomObjectInformation where Obno=Obno update guest set balance=balance-Obprice*Dnum*Obmultiple where Gno=Gno end 6.6 插入具体数据 ( 1)顾客表: insert guest values (G0001,方华 ,男上海市 ,200.0,50,1.00,100.00) insert guest values (G0002,张星 ,女重庆市 ,500.0,50,0.95,200.00) insert guest values - 29 - (G0003,郑诚 ,男北京市 ,1000.0,50,0.90,500.00) insert guest values (G0004,许佳 ,女重庆市 ,2000.0,50,0.85,800.00) insert guest values (G0005,田惠 ,女长沙市 ,3000.0,50,0.80,1100.00) insert guest values (G0006,陈东 ,男天津市 ,2500.0,50,0.80,1200.00) ( 2)房间基本信息表: insert RoomInformation values (R001,标准 1,100.0,1,正北 ) insert RoomInformation values (R002,标准 2,200.0,2,正南 ) insert RoomInformation values (R003,豪华 1,300.0,3,正西 ) insert RoomInformation values (R004,豪华 2,400.0,4,正东 ) insert RoomInformation values (R005,高级 1,500.0,5,东北 ) insert RoomInformation values (R006,高级 2,600.0,6,西南 ) ( 3)房态表: insert RoomState values (R001,G0001,2013-5-3,2013-5-5,2013-5-1,2013-5-4,200.0,2,2013-5-2,1) insert RoomState values (R002,G0002,2013-4-1,2013-4-11,2013-3-25,2013-4-5,2000.0,10,2013-5-2,2) insert RoomState values (R003,G0003,2013-4-8,2013-4-14,2013-4-1,2013-4-10,1800.0,6,2013-4-15,3) insert RoomState values (R004,G0004,2013-4-10,2013-4-10,2013-4-15,2013-4-4,2000.0,5,2013-4-6,3) insert RoomState values (R005,G0005,2013-4-15,2013-4-23,2013-4-5,2013-4-16,4000.0,8,2013-4-8,2) insert RoomState values (R006,G0006,2013-4-20,2013-4-30,2013-4-10,2013-4-22,6000.0,10,2013-4-5,1) ( 4)娱乐项目表: insert Yproject values (Y0001,温泉 ,500.0) insert Yproject values (Y0002,唱歌 ,400.0) insert Yproject values (Y0003,桑拿 ,300.0) - 30 - insert Yproject values (Y0004,汗蒸 ,200.0) insert Yproject values (Y0005,游泳 ,300.0) insert Yproject values (Y0006,足疗 ,400.0) ( 5)娱乐消费表: insert ConsumeList values (G0001,Y0001,2.0,2013-5-3) insert ConsumeList values (G0002,Y0002,1.0,2013-4-1) insert ConsumeList values (G0003,Y0003,3.0,2013-4-8) insert ConsumeList values (G0004,Y0004,2.0,2013-4-10) insert ConsumeList values (G0005,Y0005,4.0,2013-4-15) insert ConsumeList values (G0006,Y0006,1.0,2013-4-20) ( 6)房间物品信息表: insert RoomObjectInformation values (Rb001,电话机 ,2000.0,0.5) insert RoomObjectInformation values (Rb002,电视 ,1500.0,0.6) insert RoomObjectInformation values (Rb003,洗衣机 ,1800.0,0.5) insert RoomObjectInformation values (Rb004,空调 ,3000.0,0.7) insert RoomObjectInformation values (Rb005,冰箱 ,1400.0,0.5) insert RoomObjectInformation values (Rb006,电脑 ,3000.0,0.6) ( 7)物品赔偿信息表: insert ReturnObject values (G0001,R001,Rb001,1,2013-3-4) insert ReturnObject values (G0002,R002,Rb002,1,2013-4-2) insert ReturnObject values (G0003,R003,Rb003,1,2013-4-12) insert ReturnObject values - 31 - (G0004,R004,Rb004,1,2013-4-12) insert ReturnObject values (G0005,R005,Rb005,1,2013-4-18) insert ReturnObject values (G0006,R006,Rb006,1,2

温馨提示

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

评论

0/150

提交评论