系统分析与设计homework5

1、 领域建模

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

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


      系统分析与设计homework5_第1张图片
      hw5.png

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

  • 按 Task 3 要求,给出系统的 E-R 模型(数据逻辑模型)
  • 建模工具 PowerDesigner(简称PD) 或开源工具 OpenSystemArchitect
  • 不负责的链接 http://www.cnblogs.com/mcgrady/archive/2013/05/25/3098588.html
  • 导出 Mysql 物理数据库的脚本
  • 简单叙说 数据库逻辑模型 与 领域模型 的异同
系统分析与设计homework5_第2张图片
ER模型
-- MySQL Script generated by MySQL Workbench
-- Wed May  2 13:55:25 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
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `mydb` ;

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

-- -----------------------------------------------------
-- Table `mydb`.`location`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`location` ;

CREATE TABLE IF NOT EXISTS `mydb`.`location` (
  `code` INT NOT NULL,
  `name` VARCHAR(45) NULL,
  `city` VARCHAR(45) NULL,
  `region` VARCHAR(45) NULL,
  `town` VARCHAR(45) NULL,
  PRIMARY KEY (`code`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`hotel`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`hotel` ;

CREATE TABLE IF NOT EXISTS `mydb`.`hotel` (
  `name` VARCHAR(45) NOT NULL,
  `address` VARCHAR(100) NULL,
  `star` INT NULL,
  `description` VARCHAR(200) NULL,
  `hot_index` INT NULL,
  `location_code` INT NOT NULL,
  PRIMARY KEY (`name`, `location_code`),
  INDEX `fk_hotel_location1_idx` (`location_code` ASC),
  CONSTRAINT `fk_hotel_location1`
    FOREIGN KEY (`location_code`)
    REFERENCES `mydb`.`location` (`code`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`traveller`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`traveller` ;

CREATE TABLE IF NOT EXISTS `mydb`.`traveller` (
  `name` VARCHAR(45) NOT NULL,
  `gender` INT NULL,
  `email` VARCHAR(45) NULL,
  PRIMARY KEY (`name`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`reservation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`reservation` ;

CREATE TABLE IF NOT EXISTS `mydb`.`reservation` (
  `check_in_date` DATE NOT NULL,
  `check_out_date` DATE NULL,
  `room` VARCHAR(45) NULL,
  `hotel_name` VARCHAR(45) NOT NULL,
  `traveller_name` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`check_in_date`),
  INDEX `fk_reservation_hotel_idx` (`hotel_name` ASC),
  INDEX `fk_reservation_traveller1_idx` (`traveller_name` ASC),
  CONSTRAINT `fk_reservation_hotel`
    FOREIGN KEY (`hotel_name`)
    REFERENCES `mydb`.`hotel` (`name`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_reservation_traveller1`
    FOREIGN KEY (`traveller_name`)
    REFERENCES `mydb`.`traveller` (`name`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`room_infomation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`room_infomation` ;

CREATE TABLE IF NOT EXISTS `mydb`.`room_infomation` (
  `room_type` INT NOT NULL,
  `price` INT NULL,
  PRIMARY KEY (`room_type`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`room`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`room` ;

CREATE TABLE IF NOT EXISTS `mydb`.`room` (
  `room_number` INT NOT NULL,
  `is_available` TINYINT NULL,
  `room_type` INT NULL,
  `reservation_check_in_date` DATE NOT NULL,
  `room_infomation_room_type` INT NOT NULL,
  PRIMARY KEY (`room_number`),
  INDEX `fk_room_reservation1_idx` (`reservation_check_in_date` ASC),
  INDEX `fk_room_room_infomation1_idx` (`room_infomation_room_type` ASC),
  CONSTRAINT `fk_room_reservation1`
    FOREIGN KEY (`reservation_check_in_date`)
    REFERENCES `mydb`.`reservation` (`check_in_date`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_room_room_infomation1`
    FOREIGN KEY (`room_infomation_room_type`)
    REFERENCES `mydb`.`room_infomation` (`room_type`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`creditcard`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`creditcard` ;

CREATE TABLE IF NOT EXISTS `mydb`.`creditcard` (
  `creditcard_id` INT NOT NULL,
  `traveller_name` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`creditcard_id`, `traveller_name`),
  INDEX `fk_creditcard_traveller1_idx` (`traveller_name` ASC),
  CONSTRAINT `fk_creditcard_traveller1`
    FOREIGN KEY (`traveller_name`)
    REFERENCES `mydb`.`traveller` (`name`)
    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;

数据库逻辑模型 与 领域模型 的异同 :
异:领域模型是为了分析业务而建立的,它是对业务的抽象;数据库逻辑模型是为了软件开发而建立的,它是对数据库存储方式的描述。
同:它们都是对业务进行分析以后进行的可视化建模,都形象地展示了各个实体的名称、属性以及不同实体之间的联系。

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