系统分析与设计hw5(lesson7)

领域建模

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

    • 按 Task2 要求,请使用工具 UMLet,截图格式务必是 png 并控制尺寸。
    • 说明:请不要受 PCMEF 层次结构影响。你需要识别实体(E)和 中介实体(M,也称状态实体)
      • 在单页面应用(如 vue)中,E 一般与数据库构建有关, M 一般与 store 模式 有关
      • 在 java web 应用中,E 一般与数据库构建有关, M 一般与 session 有关
        系统分析与设计hw5(lesson7)_第1张图片
  2. 数据库建模(E-R 模型)

    • 按 Task 3 要求,给出系统的 E-R 模型(数据逻辑模型)
    • 建模工具 PowerDesigner(简称PD) 或开源工具 OpenSystemArchitect
    • 不负责的链接
      http://www.cnblogs.com/mcgrady/archive/2013/05/25/3098588.html
    • 导出 Mysql 物理数据库的脚本
    • 简单叙说 数据库逻辑模型 与 领域模型 的异同

E-R模型如下:
系统分析与设计hw5(lesson7)_第2张图片

脚本如下:

-- MySQL Script generated by MySQL Workbench
-- Mon Apr 30 20:40:49 2018
-- Model: New Model    Version: 1.0
-- MySQL Workbench Forward Engineering

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';

-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------

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

-- -----------------------------------------------------
-- Table `mydb`.`Traveler`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Traveler` (
  `idTraveler` INT NOT NULL,
  `name` VARCHAR(30) NOT NULL,
  `email` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`idTraveler`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`CreditCardPayment`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`CreditCardPayment` (
  `card_number` VARCHAR(20) NOT NULL,
  `security_code` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`card_number`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`Reservation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Reservation` (
  `idReservation` INT NOT NULL,
  `check_in_date` DATE NOT NULL,
  `number_of_nights` INT NOT NULL,
  `number_of_adults` INT NOT NULL,
  `number_of_children` INT NOT NULL,
  `idTraveler` INT NOT NULL,
  `idCreditCardPayment` VARCHAR(20) NOT NULL,
  PRIMARY KEY (`idReservation`),
  INDEX `idTraveler_idx` (`idTraveler` ASC),
  INDEX `idCreditCardPayment_idx` (`idCreditCardPayment` ASC),
  CONSTRAINT `idTraveler`
    FOREIGN KEY (`idTraveler`)
    REFERENCES `mydb`.`Traveler` (`idTraveler`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `idCreditCardPayment`
    FOREIGN KEY (`idCreditCardPayment`)
    REFERENCES `mydb`.`CreditCardPayment` (`card_number`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`Locatioin`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Locatioin` (
  `code` INT NOT NULL,
  `name` VARCHAR(45) NOT NULL,
  `hot` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`code`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`Hotel`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Hotel` (
  `idHotel` INT NOT NULL,
  `name` VARCHAR(45) NOT NULL,
  `star_rating` INT NOT NULL,
  `idLocation` INT NOT NULL,
  PRIMARY KEY (`idHotel`),
  INDEX `idLocation_idx` (`idLocation` ASC),
  CONSTRAINT `idLocation`
    FOREIGN KEY (`idLocation`)
    REFERENCES `mydb`.`Locatioin` (`code`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`RoomDescription`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`RoomDescription` (
  `idRoomDescription` INT NOT NULL,
  `type` VARCHAR(10) NOT NULL,
  `price` INT NOT NULL,
  PRIMARY KEY (`idRoomDescription`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`Room`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Room` (
  `room_number` INT NOT NULL,
  `isAvailable` TINYINT NOT NULL,
  `date` DATE NOT NULL,
  `idHotel` INT NOT NULL,
  `idReservation` INT NOT NULL,
  `idRoomDescription` INT NOT NULL,
  PRIMARY KEY (`room_number`),
  INDEX `idHotel_idx` (`idHotel` ASC),
  INDEX `idReservation_idx` (`idReservation` ASC),
  INDEX `idRoomDescription_idx` (`idRoomDescription` ASC),
  CONSTRAINT `idHotel`
    FOREIGN KEY (`idHotel`)
    REFERENCES `mydb`.`Hotel` (`idHotel`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `idReservation`
    FOREIGN KEY (`idReservation`)
    REFERENCES `mydb`.`Reservation` (`idReservation`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `idRoomDescription`
    FOREIGN KEY (`idRoomDescription`)
    REFERENCES `mydb`.`RoomDescription` (`idRoomDescription`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

数据库逻辑模型 与 领域模型 的异同:

  • 异:
    数据库逻辑模型是在软件的实际开发过程中建立的,它明确地给出了软件存储数据的数据类型,方式等等。
    领域模型是对领域内的概念类或现实世界中对象的可视化表示,主要是为了分析业务需求而建立的。
  • 同:
    两者都是对现实问题的抽象,它们都以图形化的形式,展示了领域中的对象以及它们之间的关系。

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