1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 网上酒店客房预定系统数据库设计

网上酒店客房预定系统数据库设计

时间:2022-02-23 21:05:35

相关推荐

网上酒店客房预定系统数据库设计

一、课程设计题目:

某酒店拟开发一个网上酒店客房预定系统,以方便客户预约订房,提高酒店管理水平。客户在入住酒店前需提供姓名、身份证号码、联系电话等个人信息在酒店网站进行预定,预定成功后酒店需发送确认信息(可以通过邮件确认),入住时需要出示确认信息。客户在预约订房时,需确认房型和入住天数,系统需要确定不同房型以及房型的数量。

本次课程设计要求设计并实现一个网上酒店客房预订系统。系统中包含两个子系统,酒店管理人员使用的订房系统、客户网上预约订房系统。

其中网上预约订房系统的前端要求是浏览器,即采用B/S模式开发。酒店管理工作人员使用的系统采用C/S模式开发,前端开发工具不限,可采用PowerBuilder, Delphi, VB,VC,Java等。后台数据库要求采用SQL SERVER或Oracle 11g及以上版本。

二、课程设计要求:

对系统的功能和数据进行需求分析、总体设计和详细设计。数据库设计部分要包含系统E-R图、数据字典、表、视图等的定义和描述。其中数据库设计要求采用辅助设计工具,例如ERWin或PowerDesigner。程序实现各项功能,在课程设计报告中要反映实现过程中采用的关键技术和主要程序流程以及主要的操作界面。对数据库的操作尽可能采用存储过程或触发器实现。

第二章系统需求分析

一、前台B/S端功能需求分析:

登陆系统。预约管理:包括查看用户的预订信息情况,发送回执信息,确定订单。入住管理:登记入住信息,分配房号等。结算管理:收取房费。查询酒店房间信息和状态。酒店经营管理:系统对收取的房费生成相应的统计分析,并提供查询功能,包括某个客房或者某个房型总的费用,某个客户收取的费用查询,整个酒店某段时间所有房间的总的费用并形成报表。参数维护。系统管理人员负责维护各种参数,包括客房的房型、房型数量、客房费用等信息。这些参数都是可以修改的,尽量提高系统的灵活性和可扩展性。系统维护。系统管理人员负责管理前台人员和客户信息、分配权限、管理密码。

二、后台C/S端功能需求分析:

该系统供客户使用,需提供以下功能:

用户注册:提供注册所需基本信息,必须实名注册。用户可修改注册信息。用户查看自己订单的状态。用户可查询指定时间的所有客房情况。用户可以在网上预订。系统每日14点之后不提供当天预约服务,客户可提前预约一个月内的客房。同一客户实名(有效证件号)在同一日只能一个房间。

三、安全性控制要求:

所有用户密码在数据库中都要求加密存储。网上预订系统要进行输入验证,防止SQL注入。系统管理员只能进行系统维护和参数维护。

第三章数据库设计

一、设计工具和基本思路:

本次数据库设计使用PowerDesigner 和SQL

1、数据库共分为五张表:Myorder、Room、RoomDetail、Customer、Manager

其中Manager为管理员信息管理表:

管理员表的E-R图(1.1)

2、以下为另外四张表的E-R图:

系统E-R图(1.2)

3、在PowerDesign中设计图为:

PowerDesigner图表(1.3)

4、数据完整性约束:

在Myorder表中定义了一个插入触发器,当更新Myorder表时,将触发该触发器,执行对Room表执行相应操作,以保证数据的完整性,SQL语句如下:

create trigger tr_insertorder

on Myorder

for insert

as

begin transaction

if exists (select RestNumber from Room Where RoomType in (select RoomType from inserted)and RestNumber<=0)

begin raiserror('error!room was sale off!',16,1)

ROLLBACK RETURN

end

DEClARE @RoomType VARCHAR(20)

set @RoomType= (select RoomType from inserted)

DECLARE @roomcount int

set @roomcount = (select roomcount from inserted)

update Room

set RestNumber = RestNumber - roomcount where RoomType=@RoomType

commit transaction

5、数据的安全性操作:

为保证用户账户的安全性,其账户密码采用MD5加密方式进行加密,即使在前台管理人员和系统管理人员处,看到的也是加密后的信息。同时由于MD5为单向加密算法,故要更改密码只能重置密钥。MD5加密算法如下:

publicclassMD5 {

//plainText加密原文,@return加密密文

publicstaticString md5(String plainText) {

byte[] secretBytes =null;

try{

secretBytes = MessageDigest.getInstance("md5").digest(

plainText.getBytes());

}catch(NoSuchAlgorithmException e) {

thrownewRuntimeException("没有md5这个算法!");

}

returnnewBigInteger(1, secretBytes).toString(16);

}

}

6、由PowerDesigner生成的建表代码为:

if exists (select 1

from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

where r.fkeyid = object_id('Myorder') and o.name = 'FK_MYORDER_REFERENCE_ROOM')

alter table Myorder

drop constraint FK_MYORDER_REFERENCE_ROOM

go

if exists (select 1

from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

where r.fkeyid = object_id('Myorder') and o.name = 'FK_MYORDER_REFERENCE_CUSTOMER')

alter table Myorder

drop constraint FK_MYORDER_REFERENCE_CUSTOMER

go

if exists (select 1

from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')

where r.fkeyid = object_id('RoomDetail') and o.name = 'FK_ROOMDETA_REFERENCE_ROOM')

alter table RoomDetail

drop constraint FK_ROOMDETA_REFERENCE_ROOM

go

if exists (select 1

from sysobjects

where id = object_id('Customer')

and type = 'U')

drop table Customer

go

if exists (select 1

from sysobjects

where id = object_id('Manager')

and type = 'U')

drop table Manager

go

if exists (select 1

from sysobjects

where id = object_id('Myorder')

and type = 'U')

drop table Myorder

go

if exists (select 1

from sysobjects

where id = object_id('Room')

and type = 'U')

drop table Room

go

if exists (select 1

from sysobjects

where id = object_id('RoomDetail')

and type = 'U')

drop table RoomDetail

go

/*==============================================================*/

/* Table: Customer */

/*==============================================================*/

create table Customer (

cId int not null,

cName varchar(10) null,

cNickname varchar(10) null,

cPassword varchar(10) null,

cSex char(2) null,

cVerifyId varchar(18) null,

cPhone varchar(11) null,

cAddress varchar(20) null,

cEmail varchar(20) null,

constraint PK_CUSTOMER primary key (cId)

)

go

/*==============================================================*/

/* Table: Manager */

/*==============================================================*/

create table Manager (

mId varchar(20) not null,

mName varchar(10) not null,

mSex char(2) not null,

mPassword varchar(10) null,

mType varchar(15) null,

constraint PK_MANAGER primary key (mId)

)

go

/*==============================================================*/

/* Table: Myorder */

/*==============================================================*/

create table Myorder (

oId int not null,

cId int null,

RoomType varchar(20) null,

roomcount int null,

status varchar(20) null,

TimeDeal datetime null,

TimeIn datetime null,

TimeOut datetime null,

constraint PK_MYORDER primary key (oId)

)

go

/*==============================================================*/

/* Table: Room */

/*==============================================================*/

create table Room (

RoomType varchar(20) not null,

Price int not null,

RestNumber int not null,

Picture varchar(100) null,

Introduce text null,

constraint PK_ROOM primary key (RoomType)

)

go

/*==============================================================*/

/* Table: RoomDetail */

/*==============================================================*/

create table RoomDetail (

RoomId int not null,

Type varchar(20) null,

Price int null,

IsEmpty varchar(5) null,

constraint PK_ROOMDETAIL primary key (RoomId)

)

go

alter table Myorder

add constraint FK_MYORDER_REFERENCE_ROOM foreign key (RoomType)

references Room (RoomType)

go

alter table Myorder

add constraint FK_MYORDER_REFERENCE_CUSTOMER foreign key (cId)

references Customer (cId)

go

alter table RoomDetail

add constraint FK_ROOMDETA_REFERENCE_ROOM foreign key (Type)

references Room (RoomType)

go

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。