数据库应用技术大作业旅馆管理系统数据库设计Word格式.docx

上传人:b****6 文档编号:18754401 上传时间:2023-01-01 格式:DOCX 页数:21 大小:25.82KB
下载 相关 举报
数据库应用技术大作业旅馆管理系统数据库设计Word格式.docx_第1页
第1页 / 共21页
数据库应用技术大作业旅馆管理系统数据库设计Word格式.docx_第2页
第2页 / 共21页
数据库应用技术大作业旅馆管理系统数据库设计Word格式.docx_第3页
第3页 / 共21页
数据库应用技术大作业旅馆管理系统数据库设计Word格式.docx_第4页
第4页 / 共21页
数据库应用技术大作业旅馆管理系统数据库设计Word格式.docx_第5页
第5页 / 共21页
点击查看更多>>
下载资源
资源描述

数据库应用技术大作业旅馆管理系统数据库设计Word格式.docx

《数据库应用技术大作业旅馆管理系统数据库设计Word格式.docx》由会员分享,可在线阅读,更多相关《数据库应用技术大作业旅馆管理系统数据库设计Word格式.docx(21页珍藏版)》请在冰豆网上搜索。

数据库应用技术大作业旅馆管理系统数据库设计Word格式.docx

●旅客特点分析:

从旅馆的角度来说,最重要的就是准确地记录旅客在住宿期间一切信息,并且要求准确

(1)lodger表用来记录旅客的信息,有lodger_name,id_num,room_num,e

checkin_date,exp_checkout_date,pre_payment

(2)lodger表用来记录当前正在发生‘入住’的旅客的信息,这个表是动态的,

如果旅客退房,与之相关的表示checkout实体集,将用户的信息载入这个表,因为退房的信息是非常关键的,因为旅店的账目的结算是要依靠这个表的,然后他的信息就会从lodger这个表中删除;

旅客可能要求‘换房'

实现这个功能的是change_room联系集

这个联系集联系了lodger和Room两个表,将原来的房间的状态修改为‘Free’,将新入住的房间修改为‘busy’;

旅客可能要求续住,我们当然会满足这个要求,实现这个要求的要求是联系集con_room,如果旅客续住那么在情况允许的情况下,可以继续在原来的房间住宿,并修改exp_checkout_date的信息,如果原来的房间已经有人预定的话,那么建议旅客更改房间,重新登记‘lodger'

信息;

●旅店的账目管理特点分析

旅店的账目管理系统是一个比较复杂的系统,要求每天都要进行更新,同时还须具备‘日结’、‘月结’、‘季度结'

、‘年结'

的功能,与此相关的是checkout,DayAccount,MonthAccount,YearAccount他们最终依赖的表都是checkout表,在我们的系统中checkout表用于记录退房用户的信息,我们并没有设定主键只是设立了外依赖,因为在这个表中不可能有两个完全相同的元组

(lodger_name,room_num,cur_date,(cur_year,cur_month,cur_day),room_account,back_change),属性(lodger_name,room_num,cur_

date,)使任意两个元组都不可能相同,因为cur_date是精确到秒的,在实际情况中具有相同lodger_name,在同一时间内从同一个房间退房时不会发生地,之所以不删除这个表的元组,是因为我们想保留这些信息以便日后的查询,比如核对账单,比如发生刑事案件需要旅店配合时,可能需要查询相关的信息……

日结DayAccount的实现也比较复杂,首先我们定制一个作业‘InsetingDayAccount’每天0:

00:

00向DayAccount插入一个用于初始化的元组,然后建立一个checkout与DayAccount之间的触发器,如果向checkout中插入信息,那么就将room_account累加到DayAccount中的day_account中去,这样就能自动统计了每天的盈利状况

MonthAccount和YearAccount的算法和DayAccount类似,同样通过定制作业和建立触发器,实现自动运算,在这就不多介绍了

二、系统概念模型(E-R图)

三、关系模式(逻辑模型)

四、物理设计(表结构)

Table1:

Room(EntitySet)

Attribute:

room_num(房间号),

room_type(房间类型),

room_price(房间价格),

room_state(房间状态),

IsBooked(预定状态)

PrimaryKey:

room_num

Table2:

Lodger(EntitySet)

Attribute:

lodger_name(客户姓名),

id_num(身份证号),

room_num(房间号),

checkin_date(入住时间),

exp_checkout_date(预期退房时间),

pe_payment(客户预付款)

lodger_num,

id_num

ForeignKey:

room_numreferencesRoom

Table3:

Room_Prebook(EntitySet)

reserve_name(预定客户姓名),

room_num(预定房间号),

exp_checkin_date(预期入住时间),

pre_payment(预付款)

PrimaryKey:

reserve_name

Table4:

DayAccount(EntitySet)

Attribute:

cur_year(年),

cur_month(月),

cur_day(日),

day_account(月结)

PrimaryKey:

cur_year,

cur_month,

cur_day

Table5:

checkout(RelationSet)

lodger_name(客户姓名),

room_num(房间号),

cur_date(日期),

(cur_year,cur_month,cur_day)(年/月/日),

live_days(住宿天数),

room_account(账单),

back_change(找零)

lodger_namereferencesLodger

room_numreferencesRoom

Table6:

MonthAccount(EntitySet)

cur_year(年),

month_account(日结)

cur_month

Table7:

YearAccount(EntitySet)

year_account(年结)

PrimaryKey:

cur_year

Table8:

Remind(EntitySet)

Attribute:

lodger_name(客户姓名),

cur_date(日期)

PrimaryKey:

lodger_name,

cur_date

ForeignKey:

lodger_name

五、系统实现

功能模块设计:

(1)客房信息管理集合

a)查询房间的空闲状态

b)查询房间的预定状态

c)查询某种类型房间的价格

d)更新某种类型房间的价格

e)更新房间的空闲状态

f)更新房间的预定状态

(2)旅客信息管理集合

a)查询入住旅客的详细信息

b)查询已预订旅客的信息

c)查询已退房旅客的信息

d)取消预定操作

e)换房操作

f)续住操作

g)退房操作

(3)旅店账户管理集合

a)退房客户结算

b)每日结算

c)每月结算

d)每年结算

(4)服务管理项目集合

a)每日提醒那些旅客已经到退房的时候

b)每日提醒那些预定的客户将在今天住进来

2。

创建数据库的SQL语句

CREATEDATABASEHotel

ON

NAME=N'

Hotel’,FILENAME=N'

E:

\Hotel\Hotel。

mdf’,SIZE=3MB,MAXSIZE=UNLIMITED,

FILEGROWTH=1MB

LOGON

NAME=N'

Hotel_log'

,FILENAME=N'

\Hotel\Hotel.ldf’,SIZE=1MB,MAXSIZE=2048GB,

FILEGROWTH=10%

GO说明:

分别建立了mdf文件和ldf文件,规定mdf文件的初始大小为3MB,增长速率为1MB每次,日志文件初始大小为1MB增长速率为10%.

3.创建表的SQL语句

(1)创建room表,存储客房信息

CREATETableRoom

room_numintnotnull,

room_statechar(10)notnull,

room_typechar(10)notnull,

room_pricechar(10)notnull,

primarykey(room_num)

(2)创建Lodger表,存储旅客信息

CREATETableLodger

lodger_namechar(20)notnull,

id_numbigintnotnull,

room_numintnotnull,

checkin_datedatetimenotnull,

exp_checkout_datedatetimenotnull,

pre_paymentmoney,

primarykey(lodger_name),

foreignkey(room_num)referencesRoom,

unique(room_num)

(3)创建Room_preBook表,用于存储预定客户信息

CREATETABLERoom_Prebook

reserve_namechar(10)notnull,

exp_checkin_datedatetimenotnull,

primarykey(reserve_name),

foreignkey(room_num)referencesRoom

(4)创建日结表,存储日结信息

CREATETableDayAccount

cur_yearint,

cur_monthint,

cur_dayint,

day_accountmoney,

(5)创建退房表,存储退房旅客信息

CREATETableCheckout

cur_datedatetimedefaultGETDATE(),

cur_yearint,

cur_monthint,

cur_dayint,

live_daysint,

room_accountmoney,

back_changemoney,

foreignkey(room_num)referencesRoom

(6)创建MonthAccount表,存储月结信息

createTableMonthAccount

cur_yearintnotnull,

cur_monthintnotnull,

Month_accountmoney,

foreignkey(cur_year)referencesDayAccount

(7)创建YearAccount表,用于存储年结信息

createTableYearAccount

cur_yearintnotnull,

year_accountintnotnull,

(8)创建Remind表,用于每日提醒

createTableRemind

lodger_namechar(20)notnull,

room_numchar(20)notnull,

cur_datedatetimedefaultgetdate()

foreignkey(lodger_name)referencesLodger)

存储过程展示:

存储过程一:

proc_query_freeroom

代码:

createprocproc_query_freeroom

as

selectroom_num,room_type,room_state

fromroom

whereroom_state=’Free’

功能:

查询当前空闲的房间

存储过程二:

proc_query_bookedroom

createprocproc_query_bookedroom

selectroom_num,room_type,IsBooked

whereIsBooked=’booked'

查询当前已经预定出去的房间

存储过程三:

proc_query_price

代码:

createprocproc_query_price

selectdistinctroom_type,room_price

查询不同类型房间的价格

存储过程四:

proc_inc_price

createprocproc_inc_price

@room_typechar(10),@new_pricemoney

updateroom

setroom_price=@new_price

whereroom_type=@room_type

功能:

更改某种类型房间的价格

存储过程五:

proc_QueryLodger

createprocedureproc_QueryLodger

@checkin_datedatetime

selectlodger_name,id_num,exp_checkout_date,pre_payment

fromlodger

wheredatepart(day,checkin_date)=datepart(day,@checkin_date)

查询指定日期入住的旅客

存储过程六:

proc_querybook

createprocproc_query_book

selectroom_num,reserve_name,exp_checkin_date,pre_payment

fromRoom_prebook

查询预订的旅客的信息

存储过程七:

proc_bookCancel

createprocedureproc_bookCancel

@reserve_namechar(20)

updateroom

setIsBooked='

nobook'

whereroom_num=(selectroom_num

fromRoom_PreBook

wherereserve_name=@reserve_name)

deletefromRoom_PreBook

wherereserve_name=@reserve_name

执行:

执行后的room_prebook表

存储过程八:

proc_changeroom

createprocproc_changeroom

@lodger_namechar(10),

@source_room_numint,

@target_room_numint

if@lodger_namein(selectlodger_namefromlodger)

and@target_room_numin(selectroom_numfromroomwhereroom_state='

Free'

begin

setroom_state='

Free’

whereroom_num=@source_room_num

Busy'

whereroom_num=@target_room_num

updatelodger

setroom_num=@target_room_num

wherelodger_name=@lodger_name

end

存储过程九:

proc_cont_lodge

createprocproc_cont_lodge

@lodger_namechar(20),

@exp_checkout_datedatetime

As

updateLodger

setexp_checkout_date=@exp_checkout_date

setroom_state=’Busy'

whereroom_num=(selectroom_num

fromlodger

wherelodger_name=@lodger_name

存储过程十:

proc_checkout_lodger

createprocedureproc_checkout_lodger

@namechar(20)

as

declare@room_numint

insertcheckout(lodger_name,room_num,cur_date,cur_year,cur_month,cur_day,live_days,room_account,back_change)

selectl。

lodger_name,

l。

room_num,

getdate(),

year(getdate()),

month(getdate()),

day(getdate()),

DATEDIFF(day,checkin_date,getdate()),

DATEDIFF(day,checkin_date,getdate())*r。

room_price,

l.pre_payment-DATEDIFF(day,checkin_date,getdate())*r.room_price

fromlodgerasl,roomasr

wherel。

lodger_name=@nameandl。

room_num=r.room_num

退房并将旅客信息插进checkout表中

存储过程十一:

proc_dayaccount_checkout

createprocedureproc_dayaccount_checkout

@cur_yearint,@cur_monthint,@cur_dayint

insertDayAccount(cur_year,cur_month,cur_day,day_account)

selectcur_year,cur_month,cur_day,sum(room_account)

fromcheckout

wherecur_year=@cur_year

and

cur_month=@cur_month

and

cur_day=@cur_day

groupbycur_year,cur_month,cur_day

对checkout表中某一天的所有盈利进行累加并将结果存入dayaccount中

存储过程十二:

proc_dayaccount

createprocedureproc_QueryDayAccount

@yearint,@monthint,@dayint

selectcur_year,cur_month,cur_day,day_account

fromDayAccount

wherecur_year=@yearandcur_month=@monthandcur_day=@day

存储过程十三:

pro

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 高等教育 > 历史学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1