01.酒店管理系统

来源:互联网 发布:如何查看数据库字符集 编辑:程序博客网 时间:2024/05/16 19:55
/*==============================================================*//* DBMS name:      Microsoft SQL Server 2005                    *//* Created on:     2017/1/2 16:06:52                            *//*==============================================================*/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('GuestRecord') and o.name = 'FK_GUESTREC_REFERENCE_ROOM')alter table GuestRecord   drop constraint FK_GUESTREC_REFERENCE_ROOMgoif 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('Room') and o.name = 'FK_ROOM_REFERENCE_ROOMSTAT')alter table Room   drop constraint FK_ROOM_REFERENCE_ROOMSTATgoif 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('Room') and o.name = 'FK_ROOM_REFERENCE_ROOMTYPE')alter table Room   drop constraint FK_ROOM_REFERENCE_ROOMTYPEgoif exists (select 1            from  sysobjects           where  id = object_id('GuestRecord')            and   type = 'U')   drop table GuestRecordgoif exists (select 1            from  sysobjects           where  id = object_id('Room')            and   type = 'U')   drop table Roomgoif exists (select 1            from  sysobjects           where  id = object_id('RoomState')            and   type = 'U')   drop table RoomStategoif exists (select 1            from  sysobjects           where  id = object_id('RoomType')            and   type = 'U')   drop table RoomTypego/*==============================================================*//* Table: GuestRecord                                           *//*==============================================================*/create table GuestRecord (   GuestID              int                  not null,   RoomID               int                  null,   GuestName            nvarchar(32)         not null,   IdentityID           varchar(36)          null,   ResideDate           datetime             null,   LeaveDate            datetime             null,   Deposit              money                null,   TotaMoney            money                null,   constraint PK_GUESTRECORD primary key (GuestID))go/*==============================================================*//* Table: Room                                                  *//*==============================================================*/create table Room (   RoomID               int                  not null,   RoomStateID          int                  null,   TypeID               int                  null,   Description          varchar(100)         null,   GuestNum             int                  null,   RoomState            varchar(2)           null,   RoomType             varchar(4)           null,   constraint PK_ROOM primary key (RoomID))go/*==============================================================*//* Table: RoomState                                             *//*==============================================================*/create table RoomState (   RoomStateID          int                  not null,   RoomStateName        varchar(32)          not null,   constraint PK_ROOMSTATE primary key (RoomStateID))go/*==============================================================*//* Table: RoomType                                              *//*==============================================================*/create table RoomType (   TypeID               int                  not null,   TypeName             varchar(32)          not null,   BedNum               int                  not null,   Price                money                not null,   constraint PK_ROOMTYPE primary key (TypeID))goalter table GuestRecord   add constraint FK_GUESTREC_REFERENCE_ROOM foreign key (RoomID)      references Room (RoomID)goalter table Room   add constraint FK_ROOM_REFERENCE_ROOMSTAT foreign key (RoomStateID)      references RoomState (RoomStateID)goalter table Room   add constraint FK_ROOM_REFERENCE_ROOMTYPE foreign key (TypeID)      references RoomType (TypeID)go

0 0
原创粉丝点击