系統分析與設計 Homework(lesson 7)

系統分析與設計 Homework(lesson 7)


領域建模

a. 閱讀 Asg_RH 文檔,按用例構建領域模型。

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

RH_DM

b. 數據庫建模(E-R 模型)

  • 按 Task 3 要求,給出系統的 E-R 模型(數據邏輯模型)
  • 建模工具 PowerDesigner(簡稱PD) 或開源工具 OpenSystemArchitect
    RH(ER)
    RH_ERModel

  • 導出 Mysql 物理數據庫的腳本

               /*==============================================================*/
    /* DBMS name:      MySQL 5.0                                    */
    /* Created on:     2018-04-29 12:14:58                          */
    /*==============================================================*/
    
    
    drop table if exists Hotel;
    
    drop table if exists Location;
    
    drop table if exists Reservation;
    
    drop table if exists Room;
    
    drop table if exists Traveler;
    
    /*==============================================================*/
    /* Table: Hotel                                                 */
    /*==============================================================*/
    create table Hotel
    (
      hotel_id             int not null,
      lid                  int not null,
      Region               char(256),
      star                 int,
      address              char(256),
      primary key (hotel_id)
    );
    
    /*==============================================================*/
    /* Table: Location                                              */
    /*==============================================================*/
    create table Location
    (
      lid                  int not null,
      Region               char(256),
      Region_code          int,
      City                 char(256),
      City_code            int,
      City_Capital         bool,
      Town                 char(256),
      primary key (lid)
    );
    
    /*==============================================================*/
    /* Table: Reservation                                           */
    /*==============================================================*/
    create table Reservation
    (
      reserve_id           int not null,
      user_id              int not null,
      hotel_id             int not null,
      check_in_date        date,
      check_out_date       date,
      nights_num           int,
      room_num             int,
      total_due            numeric(8,0),
      isPay                bool,
      make_time            datetime,
      primary key (reserve_id)
    );
    
    /*==============================================================*/
    /* Table: Room                                                  */
    /*==============================================================*/
    create table Room
    (
      room_id              int not null,
      hotel_id             int not null,
      reserve_id           int,
      type                 char(256),
      list_price           int,
      isAvailable          bool,
      primary key (room_id)
    );
    
    /*==============================================================*/
    /* Table: Traveler                                              */
    /*==============================================================*/
    create table Traveler
    (
      user_id              int not null,
      "full name"          char(256),
      "email address"      char(256),
      primary key (user_id)
    );
    
    alter table Hotel add constraint FK_exist foreign key (lid)
         references Location (lid) on delete restrict on update restrict;
    
    alter table Reservation add constraint FK_at foreign key (hotel_id)
         references Hotel (hotel_id) on delete restrict on update restrict;
    
    alter table Reservation add constraint FK_make foreign key (user_id)
         references Traveler (user_id) on delete restrict on update restrict;
    
    alter table Room add constraint FK_Has foreign key (hotel_id)
         references Hotel (hotel_id) on delete restrict on update restrict;
    
    alter table Room add constraint FK_reserve foreign key (reserve_id)
         references Reservation (reserve_id) on delete restrict on update restrict;
  • 簡單敘說數據庫邏輯模型領域模型的異同

    • 相同點
      • 都是反映不同實體之間的關係
      • 常用於系統分析與設計,特別是涉及數據表的設計
    • 不同點
      • 領域模型反映的是問題域的相關業務概念以及其關係,來源於業務需求的描述,同時可幫助用戶和需求分析人員更好的理解業務需求
      • 數據庫邏輯模型適用於軟件開發者,需考慮系統內數據的具體存放方式,比領域模型考慮方面需要更加細緻
發佈了106 篇原創文章 · 獲贊 0 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章