系统分析与设计作业5

1、 领域建模

    a. 阅读 Asg_RH 文档,按用例构建领域模型

       按 Task2 要求,请使用工具 UMLet,截图格式务必是 png 并控制尺寸

       说明:请不要受 PCMEF 层次结构影响。你需要识别实体(E)和 中介实体(M,也称状态实体)

            在 java web 应用中,E 一般与数据库构建有关, M 一般与 session 有关

            在 java web 应用中,E 一般与数据库构建有关, M 一般与 session 有关

系统分析与设计作业5_第1张图片
领域模型

    b. 数据库建模(E-R 模型)

    ·    按 Task 3 要求,给出系统的 E-R 模型(数据逻辑模型)

         建模工具 PowerDesigner(简称PD) 或开源工具 OpenSystemArchitect

        导出 Mysql 物理数据库的脚本

        简单叙说 数据库逻辑模型 与 领域模型 的异同


系统分析与设计作业5_第2张图片
E-R 模型


  -- MySQL Script generated by MySQL Workbench

-- Sun Apr 29 21:30:30 2018

-- Model: New Model    Version: 1.0

-- MySQL Workbench Forward Engineering

CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;

USE `mydb` ;

-- -----------------------------------------------------

-- Table `mydb`.`Location`

-- -----------------------------------------------------

CREATE TABLE IF NOT EXISTS `mydb`.`Location` (

  `LocationId` INT NOT NULL,

  `Name` VARCHAR(45) NULL,

  `Hotle_HotelId` INT NOT NULL,

  PRIMARY KEY (`LocationId`),

  INDEX `fk_Location_hotle_idx` (`Hotle_HotelId` ASC),

  CONSTRAINT `fk_Location_hotle`

    FOREIGN KEY (`Hotle_HotelId`)

    REFERENCES `mydb`.`Hotle` (`HotelId`)

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

ENGINE = InnoDB;

-- -----------------------------------------------------

-- Table `mydb`.`Hotle`

-- -----------------------------------------------------

CREATE TABLE IF NOT EXISTS `mydb`.`Hotle` (

  `HotelId` INT NOT NULL,

  `Name` VARCHAR(45) NOT NULL,

  `Address` VARCHAR(45) NOT NULL,

  `Location_LocationId` INT NOT NULL,

  PRIMARY KEY (`HotelId`, `Location_LocationId`),

  INDEX `fk_hotle_Location1_idx` (`Location_LocationId` ASC),

  CONSTRAINT `fk_hotle_Location1`

    FOREIGN KEY (`Location_LocationId`)

    REFERENCES `mydb`.`Location` (`LocationId`)

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

ENGINE = InnoDB;

-- -----------------------------------------------------

-- Table `mydb`.`Room`

-- -----------------------------------------------------

CREATE TABLE IF NOT EXISTS `mydb`.`Room` (

  `RoomId` INT NOT NULL,

  `Type` VARCHAR(45) NULL,

  `Hotle_HotelId` INT NOT NULL,

  PRIMARY KEY (`RoomId`, `Hotle_HotelId`),

  INDEX `fk_room_hotle1_idx` (`Hotle_HotelId` ASC),

  CONSTRAINT `fk_room_hotle1`

    FOREIGN KEY (`Hotle_HotelId`)

    REFERENCES `mydb`.`Hotle` (`HotelId`)

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

ENGINE = InnoDB;

-- -----------------------------------------------------

-- Table `mydb`.`Traveller`

-- -----------------------------------------------------

CREATE TABLE IF NOT EXISTS `mydb`.`Traveller` (

  `TravellerId` INT NOT NULL,

  `Name` VARCHAR(45) NULL,

  PRIMARY KEY (`TravellerId`))

ENGINE = InnoDB;

-- -----------------------------------------------------

-- Table `mydb`.`Reservation`

-- -----------------------------------------------------

CREATE TABLE IF NOT EXISTS `mydb`.`Reservation` (

  `ReservationId` INT NOT NULL,

  `HotelId` INT NULL,

  `TravellerId` INT NULL,

  `CheckIn` DATE NULL,

  `CheckOut` DATE NULL,

  `Traveller_TravellerId` INT NOT NULL,

  `Hotle_HotelId` INT NOT NULL,

  `Hotle_Location_LocationId` INT NOT NULL,

  `Room_RoomId` INT NOT NULL,

  `Room_Hotle_HotelId` INT NOT NULL,

  PRIMARY KEY (`ReservationId`, `Hotle_HotelId`, `Hotle_Location_LocationId`, `Room_RoomId`, `Room_Hotle_HotelId`),

  INDEX `fk_Reservation_Traveller1_idx` (`Traveller_TravellerId` ASC),

  INDEX `fk_Reservation_Hotle1_idx` (`Hotle_HotelId` ASC, `Hotle_Location_LocationId` ASC),

  INDEX `fk_Reservation_Room1_idx` (`Room_RoomId` ASC, `Room_Hotle_HotelId` ASC),

  CONSTRAINT `fk_Reservation_Traveller1`

    FOREIGN KEY (`Traveller_TravellerId`)

    REFERENCES `mydb`.`Traveller` (`TravellerId`)

    ON DELETE NO ACTION

    ON UPDATE NO ACTION,

  CONSTRAINT `fk_Reservation_Hotle1`

    FOREIGN KEY (`Hotle_HotelId` , `Hotle_Location_LocationId`)

    REFERENCES `mydb`.`Hotle` (`HotelId` , `Location_LocationId`)

    ON DELETE NO ACTION

    ON UPDATE NO ACTION,

  CONSTRAINT `fk_Reservation_Room1`

    FOREIGN KEY (`Room_RoomId` , `Room_Hotle_HotelId`)

    REFERENCES `mydb`.`Room` (`RoomId` , `Hotle_HotelId`)

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

ENGINE = InnoDB;

-- -----------------------------------------------------

-- Table `mydb`.`Payment`

-- -----------------------------------------------------

CREATE TABLE IF NOT EXISTS `mydb`.`Payment` (

  `Type` INT NULL,

  `Price` INT NULL,

  `Security code` VARCHAR(45) NULL,

  `Traveller_TravellerId` INT NOT NULL,

  `Reservation_ReservationId` INT NOT NULL,

  `Reservation_Hotle_HotelId` INT NOT NULL,

  `Reservation_Hotle_Location_LocationId` INT NOT NULL,

  INDEX `fk_Payment_Traveller1_idx` (`Traveller_TravellerId` ASC),

  INDEX `fk_Payment_Reservation1_idx` (`Reservation_ReservationId` ASC, `Reservation_Hotle_HotelId` ASC, `Reservation_Hotle_Location_LocationId` ASC),

  CONSTRAINT `fk_Payment_Traveller1`

    FOREIGN KEY (`Traveller_TravellerId`)

    REFERENCES `mydb`.`Traveller` (`TravellerId`)

    ON DELETE NO ACTION

    ON UPDATE NO ACTION,

  CONSTRAINT `fk_Payment_Reservation1`

    FOREIGN KEY (`Reservation_ReservationId` , `Reservation_Hotle_HotelId` , `Reservation_Hotle_Location_LocationId`)

    REFERENCES `mydb`.`Reservation` (`ReservationId` , `Hotle_HotelId` , `Hotle_Location_LocationId`)

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

ENGINE = InnoDB;

相同点

都是对实际问题的抽象,用于更直观的显示需求

两者都注重在对问题中的对象进行建模。 E-R模型中,问题对象为实体;领域模型中,问题对象转化为类。

两者在构建时有相似之处,领域模型需要分析所有的名词,从中提取出业务实体,区分名词中的属性,角色,实体,实例,形成操作实体集合;E-R模型的构建方法与此类似。不过稍有不同在于忽略中介实体

不同点

领域模型侧重于显示不同对象之间的关系,而不是对象内的具体实现。领域模型需要标注对象之间的对应关系(one-one, one-many, many-one, many-many). E-R模型则需要八每个实体内部也进行详细的设计。这里体现两者抽象程度的区分

E-R 模型中只涉及具体实际可视对象,即需要被记录的对象。而领域模型中显然既包括具体的实体集E, 也包含有中介实体M

你可能感兴趣的:(系统分析与设计作业5)