系統分析與設計lesson7

1、 領域建模

  • a. 閱讀 Asg_RH 文檔,按用例構建領域模型。
    • 按 Task2 要求,請使用工具 UMLet,截圖格式務必是 png 並控制尺寸
    • 說明:請不要受 PCMEF 層次結構影響。你需要識別實體(E)和 中介實體(M,也稱狀態實體)
      • 在單頁面應用(如 vue)中,E 一般與數據庫構建有關, M 一般與 store 模式 有關
      • 在 java web 應用中,E 一般與數據庫構建有關, M 一般與 session 有關


/*==============================================================*/
/* DBMS name:      Sybase SQL Anywhere 12                       */
/* Created on:     2018/4/28 21:23:29                            */
/*==============================================================*/




if exists(select 1 from sys.sysforeignkey where role='FK_HOTEL_REFERENCE_ROOM') then
    alter table hotel
       delete foreign key FK_HOTEL_REFERENCE_ROOM
end if;


if exists(select 1 from sys.sysforeignkey where role='FK_RESERVAT_REFERENCE_HOTEL') then
    alter table reservation
       delete foreign key FK_RESERVAT_REFERENCE_HOTEL
end if;


if exists(select 1 from sys.sysforeignkey where role='FK_RESERVAT_REFERENCE_PAYMENT') then
    alter table reservation
       delete foreign key FK_RESERVAT_REFERENCE_PAYMENT
end if;


if exists(select 1 from sys.sysforeignkey where role='FK_RESERVAT_REFERENCE_TRAVELLE') then
    alter table reservation
       delete foreign key FK_RESERVAT_REFERENCE_TRAVELLE
end if;


if exists(select 1 from sys.sysforeignkey where role='FK_TRAVELLE_REFERENCE_PAYMENT') then
    alter table traveller
       delete foreign key FK_TRAVELLE_REFERENCE_PAYMENT
end if;


drop table if exists hotel;


drop table if exists payment;


drop table if exists reservation;


drop table if exists room;


drop table if exists traveller;


/*==============================================================*/
/* Table: hotel                                                 */
/*==============================================================*/
create table hotel 
(
   name                 text                           not null,
   location             text                           not null,
   roomNum              int                            not null,
   phoneNum             int                            not null,
   constraint PK_HOTEL primary key clustered (name)
);


/*==============================================================*/
/* Table: payment                                               */
/*==============================================================*/
create table payment 
(
   payId                int                            not null,
   price                float                          not null,
   payTime              datetime                       not null,
   constraint PK_PAYMENT primary key clustered (payId)
);


/*==============================================================*/
/* Table: reservation                                           */
/*==============================================================*/
create table reservation 
(
   reservationId        int                            not null,
   name                 text                           null,
   payId                int                            null,
   accountId            text                           null,
   startDate            date                           not null,
   endDate              date                           not null,
   travellerId          text                           not null,
   travellerPhone       int                            not null,
   price                float                          not null,
   state                text                           not null,
   constraint PK_RESERVATION primary key clustered (reservationId)
);


/*==============================================================*/
/* Table: room                                                  */
/*==============================================================*/
create table room 
(
   roomNum              int                            not null,
   state                char                           not null,
   constraint PK_ROOM primary key clustered (roomNum)
);


/*==============================================================*/
/* Table: traveller                                             */
/*==============================================================*/
create table traveller 
(
   accountId            text                           not null,
   payId                int                            null,
   password             text                           not null,
   phoneNum             int                            not null,
   constraint PK_TRAVELLER primary key clustered (accountId)
);


alter table hotel
   add constraint FK_HOTEL_REFERENCE_ROOM foreign key (roomNum)
      references room (roomNum)
      on update restrict
      on delete restrict;


alter table reservation
   add constraint FK_RESERVAT_REFERENCE_HOTEL foreign key (name)
      references hotel (name)
      on update restrict
      on delete restrict;


alter table reservation
   add constraint FK_RESERVAT_REFERENCE_PAYMENT foreign key (payId)
      references payment (payId)
      on update restrict
      on delete restrict;


alter table reservation
   add constraint FK_RESERVAT_REFERENCE_TRAVELLE foreign key (accountId)
      references traveller (accountId)
      on update restrict
      on delete restrict;


alter table traveller
   add constraint FK_TRAVELLE_REFERENCE_PAYMENT foreign key (payId)
      references payment (payId)
      on update restrict
      on delete restrict;


    相同點:都能簡明清晰地表明數據表之間的關係,關注用例。

    不同點:領域模型更關注功能,數據庫更關注數據。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章