当前位置:数据库 > Oracle >>

【安博培训笔记】Oracle宾馆管理系统

【安博培训笔记】Oracle宾馆管理系统
 
------------------------------------------------------------------
--实现主键自增


create table t28(
       id number primary key,
       name varchar2(20)
)


insert into t28(name) values('zhangsan');


create sequence seq_name222; 


create or replace trigger tir_t28 
before insert or update on t28 for each row
begin
  select seq_name222.nextval 
         into :new.id from dual;
end;


create or replace trigger tir_t28 
before insert on t28 for each row
begin
  select seq_name222.nextval 
         into :new.id from dual;
end;


select * from t28;
update t28 set name = 'shihua' where id = 1;




-------------------------------------------
/*宾馆管理系统-综合项目
第一部分 案例描述
案例目的
  学习并巩固oracle数据库编程技术,包括存储过程、触发器、索引、视图、序列、同义词、事务、游标等,培养学生对数据库设计和程序的能力。
案例难度
  ★★★★
案例覆盖技能点
1、  存储过程
2、  触发器
3、  索引
4、  视图
5、  序列、同义词
6、  事务
7、  游标
8、  函数
推荐案例完成时间
   2天
适用课程和对象
  Oracle数据库设计
第二部分  需求和开发环境
使用技术和开发环境
  Oracle 10g
项目背景
随着我国改革开放的深入,宾馆服务业的竞争日益激烈,一个宾馆要想立于不败之地,就必须提高整体竞争能力,变革宾馆的管理模式,提高管理水平,实施信息化建设无疑是实现这一目的的必由之路和明智之举。目前,我国宾馆服务业的信息化管理进展缓慢,在激烈的竞争中,如何能把握机会,保持自己的优势,立于不败之地呢?这就需要提供最好的服务,提供最完善的设施和最先进的技术。一个成功的宾馆,其经营者不仅要提高服务水平和服务质量,从而提高客房占有率和回头率,还要有好的工作效率,并控制成本。在信息时代,更重要的是还必须要有一个完善的信息管理系统,以方便客人和更好地管理宾馆。
信息管理系统就是我们常说的MIS(Management Information System),在强调管理,强调信息的现代社会中它变得越来越普及。传统的登记表的做法极大的影响了工作流程效率和数据的正确性、完整性、安全性,已经逐渐落后于时代。利用软件管理系统代替手工的宾馆管理,将会大大提高工作效率。
案例需求
宾馆的主要活动首先可分为四个部分,即预订管理、入住管理、消费管理和退房结算管理。

预订管理主要包括登记客人的预订信息,查询预订信息,同时还需要注意预订信息不能出现冲突现象,例如两个客人都预订了同一天的同一个房间,这是不允许的;此外,在快到预订时确定的客人预抵时间时,接待人员要打电话证明客人是否能按时入住,如果不能,就会把预订单作废,或者称为失效;


除了按流程划分的这四个部分之外,还有两个部分:客房管理和用户管理。;这两部分信息需要在客人入住以前提前设定好。
*/
/*1.  用户权限管理
用户管理是管理系统的使用者,主要包括前台接待人员、前台收银员、餐厅服务员等,他们的权限按其身份不同而不同。

表名  hotel_t_User(用户表)
列名  描述  数据类型(精度范围)  空/非空  约束条件
userid  用户编号  Number  非空  主键(自增)
username  用户名称  VARCHAR2(20)  非空  
userpassword  密码  VARCHAR2(20)  非空  
truename  真实姓名  VARCHAR2(20)  非空 */ 


drop table hotel_t_User;
Create table hotel_t_User(
    userid number primary key not null,--自增
    username varchar2(20) not null,
    userpassword varchar2(20) not null,
    truename varchar2(20) not null
);
select * from hotel_t_user;
---------------


---------------------------
drop sequence seq_hotel_t_User;
create sequence seq_hotel_t_User;


drop trigger tir_hotel_t_User;
create or replace trigger tir_hotel_t_User 
before  insert or update  on hotel_t_User for each row
begin
  select seq_hotel_t_User.nextval 
         into :new.userid from dual;
end;
---------------
insert into hotel_t_User(username,userpassword,truename) 
       values('shihua','shihua','shihua');
---------------------
/*表名  hotel_t_Role(角色表)
列名  描述  数据类型(精度范围)  空/非空  约束条件
roleid  用户编号  NUMBER  非空  主键(自增)
rolename  用户名称  VARCHAR2(20)  非空*/


create table hotel_t_Role(
       roleid number primary key not null,--自增
       rolename varchar2(20) not null
);  


drop sequence seq_hotel_t_Role;
create sequence seq_hotel_t_Role;


drop trigger tir_hotel_t_Role;
create or replace trigger tir_hotel_Role 
before  insert or update  on hotel_t_Role for each row
begin
  select seq_hotel_t_Role.nextval 
         into :new.roleid  from dual;
end;


/*表名  hotel _t_Right(权限表)
列名  描述  数据类型(精度范围)  空/非空  约束条件
rightid  权限编号  NUMBER  非空  主键(自增)
rightname  权限名  VARCHAR2(50)  非空  */


create table hotel_t_Right(
       rightid number primary key not null,--自增
       rightname varchar2(20) not null
);


create sequence seq_hotel_t_Right;
create or replace trigger tir_hotel_Right 
before  insert or update  on hotel_t_Right for each row
begin
  select seq_hotel_t_Right.nextval 
         into :new.Rightid  from dual;
end;


/*表名  hotel_t_Roleright(角色权限表)
列名  描述  数据类型(精度范围)  空/非空  约束条件
rrid  编号  NUMBER  非空  主键(自增)
roleid  用户编号  NUMBER  非空  外键
rightid  权限编号  NUMBER  非空  外键*/


create table hotel_t_Roleright(
       rrid number primary key not null,--自增
       roleid number not null references hotel_t_Role(roleid),
       rightid number not null references hotel_t_Right(rightid)
);


create sequence seq_hotel_t_Roleright;
create or replace trigger tir_hotel_Roleright 
before  insert or update  on hotel_t_Roleright for each row
begin
  select seq_hotel_t_Roleright.nextval 
         into :new.rrid  from dual;
end;
/*表名  hotel_t_Userrole(用户角色表)
列名  描述  数据类型(精度范围)  空/非空  约束条件
urid  编号  NUMBER  非空  主键(自增)
roleid  用户编号  NUMBER  非空  外键
rightid  权限编号  NUMBER  非空  外键*/


create table hotel_t_Userrole(
       urid number primary key not null,--自增
       roleid number not null references hotel_t_Role(roleid),
       rightid number not null references hotel_t_Right(rightid)
);


create sequence seq_hotel_t_Userrole;
create or replace trigger tir_hotel_Userrole 
before  insert or update  on hotel_t_Userrole for each row
begin
  select seq_hotel_t_Userrole.nextval 
         into :new.urid  from dual;
end;
/*主要功能模块涉及的数据表的关系图:

2.  客房基本信息管理
客房管理主要是按客房的条件不同,对客房进行分类(例如分成标准间和豪华间),每一类制定一个标价,但实际上这个标价很少按照执行,为了迎合客人心理,各个宾馆一般都会对标价进行打折,即便这样,有的客人可能还不满意,或者是打折后出现零钱的现象,宾馆一般会给接待人员一个让价的权利,但是这个让价不能是无限度的,因此还需要对每类房间定一个最低价
表名  hotel_t_Roomtype(客房类型表)
列名  描述  数据类型(精度范围)  空/非空  约束条件
typeid  类型编号  NUMBER  非空  主键(自增)
typename  类型名称  VARCHAR2(20)  非空  
mardedprice  标价  NUMBER(12,2)  空  
scale  折扣比率  NUMBER(5,4)  空  
lowestprice  最低折扣价  NUMBER(12,2)  空 */ 


create table hotel_t_Roomtype(
        typeid NUMBER primary key not null, --自增
        typename VARCHAR2(20)  not null,  
        mardedprice NUMBER(12,2),  
        scale NUMBER(5,4),
        lowestprice NUMBER(12,2)
)


create sequence seq_hotel_t_Roomtype;
create or replace trigger tir_hotel_Roomtype 
before  insert or update  on hotel_t_Roomtype for each row
begin
  select seq_hotel_t_Roomtype.nextval 
         into :new.typeid  from dual;
end;


/*表名  hotel_t_Room(客房信息表)
列名  描述  数据类型(精度范围)  空/非空  约束条件
roomid  房号  VARCHAR2(10)  非空  主键
typeid  类型编号  NUMBER  空  外键
layer  楼层  VARCHAR2(20)  空  
bednumber  床位数  NUMBER  空  
state  状态  NUMBER  非空  0表示空闲,1表示入住,2表示预留,默认为0*/


create table hotel_t_Room(--(客房信息表)
--列名  描述  数据类型(精度范围)  空/非空  约束条件
roomid VARCHAR2(10) primary key,--  非空  主键
typeid NUMBER references hotel_t_Roomtype(typeid),--  空  外键
layer VARCHAR2(20),--  空  
bednumber NUMBER,--  空  
state NUMBER default 0 check(state in (0,1,2)) not null  --0表示空闲,1表示入住,2表示预留,默认为0
);
/*3.  预订管理模块
预订管理主要包括登记客人的预订信息,查询预订信息,同时还需要注意预订信息不能出现冲突现象,例如两个客人都预订了同一天的同一个房间,这是不允许的;此外,在快到预订时确定的客人预抵时间
Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,