酒店管理系統 資料庫課程設計

2021-03-14 12:00:08 字數 5203 閱讀 6139

insert into 客戶 values('1003','李四',56465,'江西','5654645')

insert into 客戶 values('1004','王錢',65435,'江西','5676577')

insert into 客戶 values('1005','孫志',11464,'江西','4234343')

(4)建立入住登記表

create table 入住登記

(客房編號 char(8)foreign key references 客房(客房編號),

客戶編號 char(8)foreign key references 客戶(客戶編號),

預定日期 datetime,

預定數量 int,

primary key(客房編號,客戶編號))

insert into 入住登記 values('101','1001',2010-10-10,1)

insert into 入住登記 values('102','1002',2010-12-10,1)

insert into 入住登記 values('103','1003',2010-12-26,1)

insert into 入住登記 values('104','1004',2010-12-9,1)

建立查詢檢視

1.2系統功能相應的查詢檢視:

(1)客戶資訊查詢檢視

create view 客戶資訊查詢

as select * from 客戶

(2)客房資訊查詢

create view 客房資訊查詢

as select * from 客房

(3)入住資訊查詢

create view 入住登記資訊查詢

as select * from 入住登記

(4)入住資訊查詢

create view 入住資訊查詢

as select入住登記.客房編號,客戶名稱,入住登記.客戶編號,客房.客房型別,**,使用狀態

from 客房,客戶,入住登記

where 客房.客房編號=入住登記.客房編號 and 入住登記.客戶編號=客戶.客戶編號

建立索引

1.3建立索引及資料入庫

1.建立客房編號,**,客戶編號,客戶名稱的索引

建立客房表索引:

create unique index ukf on 客房(客房編號,**)

建立客戶表索引:

create unique index ukh on 客戶(客戶編號,客戶名稱)

建立入住表索引:

create unique index urz on 入住登記(客戶編號,客房編號)

2.資料入庫

方法一酒店管理系統包括客房資訊表,客戶資訊表,入住登記資訊表。採用excel中錄入資料,然後使用sql server 2000資料匯入、匯出功能直接將資料匯入到相應的基本表。

方法二在查詢分析器中插入相關資料,用sql語句插入。

建立儲存過程

1.4建立儲存過程

1.4.1客房資訊儲存過程

插入客房資訊儲存過程:

create procedure 插入客房資訊

(@kfb char(8),

@kfl char(8),

@jg **allmoney,

@cws int,

@syzt char(8))as

insert into 客房 values (@kfb,@kfl,@jg,@cws,@syzt)

修改客房資訊儲存過程:

create procedure 修改客房資訊

(@kfb char(8),

@kfl char(8),

@jg **allmoney,

@cws int,

@syzt char(8))as

update 客房

set 客房型別=@kfl,**=@jg,床位數=@cws,使用狀態=@syzt

where 客房編號=@kfb

刪除客房資訊儲存過程:

create procedure 刪除客房資訊

(@kfb char(8))as

delete from 客房 where 客房編號=@kfb

1.4.2客戶資訊儲存過程

插入客戶資訊

create procedure 插入客戶資訊

(@khb char(8),

@kfm char(10),

@sfz char(18),

@lxdz char(25),

@lxdh char(10))as

insert into 客戶 values (@khb,@kfm,@sfz,@lxdz,@lxdh)

修改客戶資訊

create procedure 修改客戶資訊

(@khb char(8),

@kfm char(10),

@sfz char(18),

@lxdz char(25),

@lxdh char(10))as

update 客戶

set 客戶名稱=@kfm,身份證號=@sfz,聯絡位址=@lxdz,聯絡**=@lxdh

where 客戶編號=@khb

刪除客戶資訊

create procedure 刪除客戶資訊

(@khb char(8))

asdelete

from 客戶

where 客戶編號=@khb

exec 刪除客戶資訊 @khb='10009'

3.4.3建立入住資訊儲存過程

插入入住資訊

create procedure 插入入住資訊

(@kfb char(8),

@khb char(8),

@ydrq datetime,

@ydsl int)as

insert into 入住登記 values(@kfb,@khb,@ydrq,@ydsl)

修改入住資訊

create procedure 修改入住資訊

(@kfb char(8),

@khb char(8),

@ydrq datetime,

@ydsl int)as

update 入住登記

set 客房編號=@kfb,預定日期=@ydrq ,預定數量=@ydsl

where 客戶編號=@khb

刪除入住資訊

create procedure 刪除入住資訊

( @khb char(8))as

delete

from 入住登記

where 客戶編號=@khb

1.5查詢儲存過程的建立

客房編號查詢

create procedure 客房編號查詢

(@kfb char(8),

@kfl char(8)output,

@jg **allmoney output,

@cws int output,

@syzt char(8)output)as

select @kfl=客房型別,@jg=**,@cws=床位數,@syzt=使用狀態

from 客房

where 客房編號=@kfb

客戶編號查詢

create procedure 客戶編號查詢

(@khb char(8),

@kfm char(10)output ,

@sfz char(18)output,

@lxdz char(25)output,

@lxdh char(10)output)as

select @kfm=客戶名稱,@sfz=身份證號,@lxdz=聯絡位址,@lxdh=聯絡**

from 客戶

where 客戶編號=@khb

入住客戶編號查詢

create procedure 入住客戶編號查詢

(@kfb char(8)output,

@khb char(8),

@ydrq datetime output,

@ydsl int output)as

select @kfb=客房編號,@ydrq=預定日期,@ydsl=預定數量

from 入住登記

where 客戶編號=@khb

建立觸發器

1.6、建立觸發器保證資料的一致性

客房使用狀態的控制

create trigger 控制觸發器

on 入住登記

for insert

asupdate 客房

set 使用狀態='使用中'

where 客房編號=any (select 客房編號 from inserted )

控制入住資訊刪除的觸發器

create trigger 入住刪除觸發器

on 入住登記

for delete

as begin

delete

from 客戶

where 客戶編號=any (select 客戶編號 from deleted )

update 客房

set 使用狀態='未使用'

where 客房編號=any(select 客房編號 from deleted)

end客戶資訊刪除的控制

create trigger 客戶刪除觸發器

on 客戶

for delete

as begin

delete

from 入住

where 客戶編號=any (select 客戶編號 from deleted )

update 客房

set 使用狀態='未使用'

where 客房編號=any(select 客房編號 from deleted)

end客房刪除觸發器

create trigger 客房刪除觸發器

on 客房

for delete

as delete

from 入住

where 客戶編號=any (select 客戶編號 from deleted )

酒店管理系統資料庫指令碼

資料庫初始化

set nocount on

set dateformat mdy

go use master

goif exists(select * from sysdatabases where name='酒店管理系統') /*刪除在master中已存*/ /*在的名為酒店管理系統的資料庫*/

資料庫課程設計酒店管理系統

酒店管理系統 背景說明 目前大多數酒店提供的服務多種多樣,規模大小也各不相同,但稍具規模的酒店必含下面三類服務 飲食 住宿和娛樂。由於我們對酒店行業沒有具體的接觸和實質性的了解。此次資料庫設計只能在一些收集到的基本材料與個人直觀認識的基礎上,簡單模仿中等規模的酒店設計管理系統,並將其抽象成乙個由三部...

資料庫課程設計酒店管理系統

第一章客房管理系統概述 1.1系統開發的背景 隨著社會的的不斷進步,賓館酒店業的競爭也愈來愈激烈,要想在競爭中取得優勢,必須在經營管理 產品服務等方面提高管理意識。如何利用先進的管理手段,提高客房 的管理水平,是每乙個賓館管理者所面臨的重大問題。傳統手工的客房管理,管理過繁瑣而複雜,執行效率低,並且...

資料庫課程設計酒店管理系統

第一章客房管理系統概述 1.1系統開發的背景 隨著社會的的不斷進步,賓館酒店業的競爭也愈來愈激烈,要想在競爭中取得優勢,必須在經營管理 產品服務等方面提高管理意識。如何利用先進的管理手段,提高客房 的管理水平,是每乙個賓館管理者所面臨的重大問題。傳統手工的客房管理,管理過繁瑣而複雜,執行效率低,並且...