
所在系:计算机科学系
专业:计算机网络技术
项目名称:酒店客房管理系统
项目组长: XX
项目组成员:XX、XX、XX
2012年10月
酒店客房管理系统
1、案例背景
酒店客房管理系统是一个酒店管理部门不可缺少的部分,它的内容对于酒店管理的决策者和住宿客户来说都至关重要,所以酒店客房管理系统应该能够为酒店管理人员提供充足的信息和快捷的查询手段。传统的人工安排酒店住宿信息需要填写各种表格,这种管理方式存在着许多缺点,如:效率低,保密性差,更新不及时等问题。因此,开发一套这样酒店客房管理软件成为很有必要的事情。
2、案例需求
(1)系统性质:MIS软件
(2)系统使用者:管理人员
(3)根据系统的初步要求,整理出如下的系统功能由客房管理、客户管理、预定管理和退房管理4个部分组成。
•客房管理
1)客房的基本信息包括客房的编号、客房的类别、价位、当前的状态、负责人等。
2)查询某一负责人负责客房的数目。
•客户管理
1)录入客户的基本情况,包括客户的身份证号、姓名、客房编号。
2)对已退房的客户,删除客户相关信息。
•预定管理
1)提供查询当前处于“空闲”状态的客房信息。
2)查询某客户预定的客房编号。
•退房管理
1)提供修改已退客房的当前状态信息,由“住宿”改为“空闲”。
3、需要完成的任务:
1)根据需求分析的说明完成系统功能图。
2)概念结构设计(要求:分析系统的实体,属性和联系,完成系统E-R图或局部功能E-R图)。
3)逻辑结构设计(要求:将E-R图转换成关系模式,分析各关系模式的范式等级,给出各关系模式的表格结构,如下图,确定表中各属性的类型、长度、是否为主键等信息)。
4)数据库实施(要求:根据上述关系模式,使用SQL命令创建数据库和数据表)。
5)设计SQL命令的查询。(要求:SQL命令能完成相应的系统功能)
6)设计测试用例(使用有效数据测试SQL命令的正确性)。
目 录
1 需求分析 5
2 概念结构设计 ==5
3 逻辑结构设计 5
4 数据库实施 5
5 设计SQL查询命令 6
6 设计测试用例 6
1 需求分析
酒店客房管理系统主要包含客房管理、客户管理、预订管理、退房管理四个主要功能,其系统功能模块图如下所示:
2 概念结构设计
经分析可知,酒店客房管理系统的实体包括:
客房:编号,类别,价位,当前状态,负责人
客户:身份证号,姓名,客房编号
各实体间的联系描述如下:
1个客户可以预订多个客房,1个客房只能有一个客户预订
1个客户可以退房多个客房,1个客房只能有一个客户退房
系统的完整E-R图/局部E-R图如下所示:
酒店客房管理系统全局E-R图
n n
1 1
3 逻辑结构设计
根据E-R图向关系模式转换的原则,作如下设计:
(1)将实体转换成的关系模式:
客房(编号,类别,价位,当前状态,负责人)
客户(身份证号,姓名,客房编号)
(2)将联系转换成相应的关系模式:
预订(身份证号,编号)
退房(身份证号,编号)
预订和退房均与客房实体集对应的关系模式合并,合并后的关系模式为:
客房(编号,类别,价位,当前状态,负责人,身份证号)
综上分析,酒店客房管理系统包含的关系模式如下:
客户信息表
| 列名 | 数据类型 | 长度 | 是否为主键 | 是否为空 | 备注 |
| Cname | Char | 10 | 否 | 否 | 姓名 |
| CIDnum | Char | 20 | 是 | 否 | 身份证号 |
| 列名 | 数据类型 | 长度 | 是否为主键 | 是否为空 | 备注 | ||||||
| Rnum | Char | 10 | 是 | 否 | 客房编号 | ||||||
| Rtype | Char | 12 | 否 | 否 | 客房类型 | ||||||
| Rprice | Float | 12 | 否 | 否 | 客房价格 | ||||||
| Rstates | Char | 10 | 否 | 否 | 客房状态 | ||||||
| Rperson | Char | 10 | 否 | 否 | 负责人 | ||||||
| CIDnum | Char | 20 | 否 | 否 | 身份证号 | ||||||
1、使用SQL命令创建数据库
create database hotel
2、使用SQL命令创建数据表
create table Custom
(
Cname char(10) not null,
CIDnum char(20) primary key not null,
)
create table Room
(
Rnum char(10) primary key not null,
Rtype char(12) not null,
Rprice float(12) not null,
Rstates char(10) not null,
Rperson char(10) not null,
CIDnum char(20)
)
5 设计SQL查询命令
1、客房管理模块中相应功能的实现:
(1)登记客户信息
原理:
insert into Custom(Cname,CIDnum)
values('相应信息','相应信息');
举例:
insert into Custom(Cname,CIDnum)
values('张三','421222199301010001');
insert into Custom(Cname,CIDnum)
values('李四','421222199301010002');
insert into Custom(Cname,CIDnum)
values('王五','421222199301010003');
insert into Custom(Cname,CIDnum)
values('小明','421222199301010004');
insert into Custom(Cname,CIDnum)
values('小红','421222199301010005');
或打开表直接添加:
(2)查询客户信息
原理:
查询客户所有信息:
select Cname,Custom.CIDnum,Rnum,Rtype,Rperson,Rstates,Rprice
from Custom,Room
where Custom.CIDnum=Room.CIDnum and Custom.CIDnum='查询客户身份证号'
举例:
查询客户所有信息:
select Cname,Custom.CIDnum,Rnum,Rtype,Rperson,Rstates,Rprice
from Custom,Room
where Custom.CIDnum=Room.CIDnum and Custom.CIDnum='421222199301010001'
查询身份证为421222************的客户的所有信息
(3)修改客户信息
原理:
update Custom set Cname='改后数据' where CIDnum='号码'
举例:
update Custom set Cname ='小芳' where CIDnum=' 421222199301010006'
把身份证号为'421222199301010006'的客户姓名改为小芳
或打开表直接修改:
(4)删除客户信息
原理:
delete from Custom
where CIDnum='需要删除信息的人的身份证';
举例:
delete from Custom
where CIDnum='421222199301010006';
把身份证号为421222************的客户信息删除
(5)登记客房信息
原理:
insert into Room(Rnum,Rtype,Rprice,Rstates,Rperson,CIDnum)
values('相应数据','相应数据','相应数据','相应数据','相应数据','相应数据');
举例:
insert into Room(Rnum,Rtype,Rprice,Rstates,Rperson,CIDnum)
values('001','套房','250','入住','李祥','421222199301010001');
insert into Room(Rnum,Rtype,Rprice,Rstates,Rperson,CIDnum)
values('002','豪华','200','入住','殷冲','421222199301010002');
insert into Room(Rnum,Rtype,Rprice,Rstates,Rperson,CIDnum)
values('003','标准','150','入住','王浩','421222199301010003');
insert into Room(Rnum,Rtype,Rprice,Rstates,Rperson,CIDnum)
values('004','标准','150','入住','乐志成','421222199301010004');
insert into Room(Rnum,Rtype,Rprice,Rstates,Rperson,CIDnum)
values('005','经济','100','入住','大张俊','421222199301010005');
insert into Room(Rnum,Rtype,Rprice,Rstates,Rperson,CIDnum)
values('006','经济','100','空闲','大张俊','NULL');
或者直接添加数据:
(6)查询客房信息
原理:
查询客户所有信息:
select Cname,Custom.CIDnum,Rnum,Rtype,Rperson,Rstates,Rprice
from Custom,Room
where Custom.CIDnum=Room.CIDnum and Room.Rnum='要查询客房编号'
查询负责人负责数目:
select Rperson,count(Rperson) as '负责数目'
from Room
where Rperson='要查询负责人名'
group by Rperson
举例:
查询客户所有信息:
select Cname,Custom.CIDnum,Rnum,Rtype,Rperson,Rstates,Rprice
from Custom,Room
where Custom.CIDnum=Room.CIDnum and Room.Rnum='001'
查询客房编号为001的客房的所有信息
查询负责人负责数目:
select Rperson,count(Rperson) as '负责数目'
from Room
where Rperson='李祥'
group by Rperson
查询负责人李祥负责的客房数目
(7)修改客房信息
原理:
update Room set Rperson='改后数据' where Rnum='号码'
update Room set Rprice='改后数据' where Rnum='号码'
举例:
update Room set Rperson='李祥' where Rnum='002'
update Room set Rprice='130' where Rnum='002'
把2号客房的负责人改为李祥,把2号客房的价格改为130
或者直接打开表修改:
(8)预订信息登记
1.查询客房状态
select Rnum,Rstates
from Room
where Rstates='空闲'
2.修改客房状态
例如选定了006号房间预订客户身份证为421222************
update Room set Rstates='预定',CIDnum='421222199301010007'
where Rnum='006'
(9)预订信息修改
取消预订:
例如身份证为421222************的客户要取消预订
update Room set Rstates='空闲',CIDnum='NULL'
where CIDnum='421222199301010007'
(10)预订信息查询
原理:
查询客户预订的客房所有信息:
select *
from Room
where CIDnum='查询的客户身份证号'
查询客户预订的客房编号:
select Rnum,CIDnum
from Room
where CIDnum='查询的客户身份证号'
举例:
查询客户预订的客房所有信息:
select *
from Room
where CIDnum='421222199301010007'
例如身份证号为421222************的客户要查询自己客房信息
查询客户预订的客房编号:
select Rnum,CIDnum
from Room
where CIDnum='421222199301010007'
例如身份证号为421222************的客户要查询自己客房编号
(11)退房登记
原理:
update Room set Rstates='空闲',CIDnum='NULL'
where CIDnum='退房客户身份证'
举例:
update Room set Rstates='空闲',CIDnum='NULL'
where CIDnum='421222199301010005'
例如身份证号为421222************的客户要退房
(12)退房修改
同退房登记
6设计测试用例
1、设计测试数据:
例如现阶段已有的客户和客房表
客户表:
| Cname | CIDnum |
| 张三 | 421222199301010001 |
| 李四 | 421222199301010002 |
| 王五 | 421222199301010003 |
| 小明 | 421222199301010004 |
| 小红 | 421222199301010005 |
| Rnum | Rtype | Rprice | Rstates | Rperson | CIDnum |
| 001 | 套房 | 250 | 入住 | 李祥 | 421222199301010001 |
| 002 | 豪华 | 200 | 入住 | 殷冲 | 421222199301010002 |
| 003 | 标准 | 150 | 入住 | 王浩 | 421222199301010003 |
| 004 | 标准 | 150 | 入住 | 乐志成 | 421222199301010004 |
| 005 | 经济 | 100 | 入住 | 大张俊 | 421222199301010005 |
| 006 | 经济 | 100 | 空闲 | 大张俊 | NULL |
2.‘小刚’想要住宿,需要一个经济房,他的身份证号为‘421222************’。
3.‘小军’也想住宿,需要一个套房,他的身份证号为‘421222************’。
4.‘小芳’对信息出错耿耿于怀,于是决定退房,很不高兴的离开了。
5.‘张三’住够了也要退房,退完房,很高兴的走了。
6.‘小华’想要预订一套套房,他的身份证号为‘421222************’。
7.‘小强’刚好想要预订一套经济房,他的身份证号为‘421222************’。
8.‘小强’想要查询自己预订的房间编号和自己房间的负责人‘大张俊’负责的客房数和类型。
9.‘小强’对自己的负责人的能力很怀疑于是决定取消预订。
10.‘王五’对自己的负责人不太满意想要更换负责人为‘李祥’,换完觉得很满意,很高兴。
……
2、检验SQL命令实现的功能
创建数据库和数据表
create database hotel
create table Custom
(
Cname char(10) not null,
CIDnum char(20) primary key not null,
)
create table Room
(
Rnum char(10) primary key not null,
Rtype char(12) not null,
Rprice float(12) not null,
Rstates char(10) not null,
Rperson char(10) not null,
CIDnum char(20)
)
输入顾客表格数据
insert into Custom(Cname,CIDnum)
values('张三','421222199301010001');
insert into Custom(Cname,CIDnum)
values('李四','421222199301010002');
insert into Custom(Cname,CIDnum)
values('王五','421222199301010003');
insert into Custom(Cname,CIDnum)
values('小明','421222199301010004');
insert into Custom(Cname,CIDnum)
values('小红','421222199301010005');
输入客房表数据
insert into Room(Rnum,Rtype,Rprice,Rstates,Rperson,CIDnum)
values('001','套房','250','入住','李祥','421222199301010001');
insert into Room(Rnum,Rtype,Rprice,Rstates,Rperson,CIDnum)
values('002','豪华','200','入住','殷冲','421222199301010002');
insert into Room(Rnum,Rtype,Rprice,Rstates,Rperson,CIDnum)
values('003','标准','150','入住','王浩','421222199301010003');
insert into Room(Rnum,Rtype,Rprice,Rstates,Rperson,CIDnum)
values('004','标准','150','入住','乐志成','421222199301010004');
insert into Room(Rnum,Rtype,Rprice,Rstates,Rperson,CIDnum)
values('005','经济','100','入住','大张俊','421222199301010005');
insert into Room(Rnum,Rtype,Rprice,Rstates,Rperson,CIDnum)
values('006','经济','100','空闲','大张俊','NULL');
1.‘小红’想要查找自己的信息,发现信息有误,很生气,要将自己的姓名改为‘小芳’,并且要求降低价格至80元。
select *
from Custom,Room
where Custom.CIDnum=Room.CIDnum and Custom.CIDnum='421222199301010005'
查询身份证号为'421222199301010005'的客户全部信息即‘小红’的信息
update Custom set Cname='小芳'
where CIDnum='421222199301010005'
update Room set Rprice='80'
where CIDnum='421222199301010005'
select *
from Custom,Room
where Custom.CIDnum=Room.CIDnum and Custom.CIDnum='421222199301010005'
修改身份证号为'421222199301010005'的客户的姓名和住房价格
2.‘小刚’想要住宿,需要一个经济房,他的身份证号为‘421222************’。
update Room set CIDnum='421222199301010006',Rstates='入住'
where Rnum in
(
select Rnum
from Room
where Rtype='经济' and Rstates='空闲'
)
insert into Custom(Cname,CIDnum)
values('小刚','421222199301010006');
select *
from Custom,Room
where Custom.CIDnum=Room.CIDnum and Custom.CIDnum='421222199301010006'
3.‘小军’也想住宿,需要一个套房,他的身份证号为‘421222************’。
update Room set CIDnum='421222199301010007'
where Rnum in
(
select Rnum
from Room
where Rtype='套房' and Rstates='空闲'
)
0行受影响故没有满足要求的房间,无法住宿
4.‘小芳’对信息出错耿耿于怀,于是决定退房,很不高兴的离开了。
update Room set Rstates='空闲',CIDnum='NULL'
where CIDnum='421222199301010005'
delete from Custom
where CIDnum='421222199301010005';
select *
from Custom
select *
from Room
5.‘张三’住够了也要退房,退完房,很高兴的走了。
update Room set Rstates='空闲',CIDnum='NULL'
where CIDnum='421222199301010001'
delete from Custom
where CIDnum='421222199301010001';
select *
from Custom
select *
from Room
6.‘小华’想要预订一套经济房,他的身份证号为‘421222************’。
update Room set Rstates='预定',CIDnum='421222199301010008'
where Rnum in
(
select Rnum
from Room
where Rstates='空闲' and Rtype='套房'
)
insert into Custom(Cname,CIDnum)
values('小华','421222199301010008')
select *
from Custom
select *
from Room
7.‘小强’刚好想要预订一套经济房,他的身份证号为‘421222************’。
update Room set Rstates='预定',CIDnum='421222199301010009'
where Rnum in
(
select Rnum
from Room
where Rstates='空闲' and Rtype='经济'
)
insert into Custom(Cname,CIDnum)
values('小强','421222199301010009')
select *
from Custom
select *
from Room
8.‘小强’想要查询自己预订的房间编号和自己房间的负责人‘大张俊’负责的客房总数、客房编号和类型。
select Rnum,CIDnum
from Room
where CIDnum='421222199301010009'
select Rperson,count(Rperson) as '负责数目'
from Room
where Rperson='大张俊'
group by Rperson
select Rperson,Rtype,Rnum
from Room
where Rperson='大张俊'
9.‘小强’对自己的负责人的能力很怀疑于是决定取消预订。
update Room set Rstates='空闲',CIDnum='NULL'
where CIDnum='421222199301010009'
delete from Custom
where CIDnum='421222199301010009'
select *
from Custom
select *
from Room
10.‘王五’对自己的负责人不太满意想要更换负责人为‘李祥’,换完觉得很满意,很高兴。
update Room set Rperson='李祥'
where CIDnum='421222199301010003'
select *
from Room
