系统分析与设计作业 5(lesson 7)

    • 领域建模
      • 阅读 Asg_RH 文档,按用例构建领域模型。
    • 数据库建模(ER 模型)
      • ER 模型图
      • 导出 MySQL 数据库脚本
      • 简单叙说 数据库逻辑模型 与 领域模型 的异同

领域建模

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

系统分析与设计作业 5(lesson 7)_第1张图片

数据库建模(ER 模型)

建模工具 MySQL Workbench

ER 模型图

系统分析与设计作业 5(lesson 7)_第2张图片

导出 MySQL 数据库脚本

-- MySQL Script generated by MySQL Workbench
-- Sun Apr 29 19:59:53 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`.`Location`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Location` (
  `code` INT NOT NULL,
  `name` VARCHAR(45) NULL,
  `hot` TINYINT NULL,
  PRIMARY KEY (`code`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`Hotel`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Hotel` (
  `id` INT NOT NULL,
  `name` VARCHAR(45) NULL,
  `star` INT NULL,
  `Location_code` INT NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_Hotel_Location_idx` (`Location_code` ASC),
  CONSTRAINT `fk_Hotel_Location`
    FOREIGN KEY (`Location_code`)
    REFERENCES `mydb`.`Location` (`code`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`RoomDesc`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`RoomDesc` (
  `id` INT NOT NULL,
  `desc` VARCHAR(45) NULL,
  `listprice` JSON NULL,
  `Hotel_id` INT NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_RoomDesc_Hotel1_idx` (`Hotel_id` ASC),
  CONSTRAINT `fk_RoomDesc_Hotel1`
    FOREIGN KEY (`Hotel_id`)
    REFERENCES `mydb`.`Hotel` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`Room`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Room` (
  `id` INT NOT NULL,
  `date` DATE NULL,
  `isAvaliable` TINYINT NULL,
  `RoomDesc_id` INT NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_Room_RoomDesc1_idx` (`RoomDesc_id` ASC),
  CONSTRAINT `fk_Room_RoomDesc1`
    FOREIGN KEY (`RoomDesc_id`)
    REFERENCES `mydb`.`RoomDesc` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`Account`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Account` (
  `id` INT NOT NULL,
  `username` VARCHAR(45) NULL,
  `passwd` VARCHAR(45) NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`Sale`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Sale` (
  `id` INT NOT NULL,
  `money` DOUBLE NULL,
  `ispaid` TINYINT NULL,
  `Room_id` INT NOT NULL,
  `Account_id` INT NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_Sale_Room1_idx` (`Room_id` ASC),
  INDEX `fk_Sale_Account1_idx` (`Account_id` ASC),
  CONSTRAINT `fk_Sale_Room1`
    FOREIGN KEY (`Room_id`)
    REFERENCES `mydb`.`Room` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_Sale_Account1`
    FOREIGN KEY (`Account_id`)
    REFERENCES `mydb`.`Account` (`id`)
    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;

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

相同点:在“实体”的概念上有相似点,都描述了实体间的关系,每个实体有对应的属性。

不同点:领域模型构建的是针对实际场景的问题以及解决方案的对象,构建的是对象的行为; 而数据库模型构建的是数据本身以及其存储, 即数据的存储结构。

你可能感兴趣的:(数据库,编程素质,er,model)