a.领域建模
阅读 Asg_RH 文档,按用例构建领域模型。
按 Task2 要求,请使用工具 UMLet,截图格式务必是 png 并控制尺寸
说明:请不要受 PCMEF 层次结构影响。你需要识别实体(E)和 中介实体(M,也称状态实体)
在单页面应用(如 vue)中,E 一般与数据库构建有关, M 一般与 store 模式 有关
- 在 java web 应用中,E 一般与数据库构建有关, M 一般与 session 有关
b. 数据库建模(E-R 模型)
按 Task 3 要求,给出系统的 E-R 模型(数据逻辑模型)
导出 Mysql 物理数据库的脚本
-- MySQL Script generated by MySQL Workbench
-- Sun Apr 29 20:22:29 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) NOT NULL,
`hot` FLOAT NULL,
`type` VARCHAR(45) NOT NULL,
PRIMARY KEY (`code`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`hotel`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`hotel` (
`name` VARCHAR(45) NOT NULL,
`star` TINYINT NULL,
`hot_index` FLOAT NULL,
`address` VARCHAR(100) NOT NULL,
`lowest_price` DECIMAL NULL,
`description` TEXT NULL,
`location_code` INT NOT NULL,
PRIMARY KEY (`name`, `location_code`),
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`.`room_information`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`room_information` (
`info_id` INT NOT NULL,
`type` VARCHAR(45) NOT NULL,
`list_price` DECIMAL NOT NULL,
PRIMARY KEY (`info_id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`customer`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`customer` (
`name` VARCHAR(45) NOT NULL,
`email` VARCHAR(45) NOT NULL,
PRIMARY KEY (`name`, `email`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`reservation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`reservation` (
`reserve_id` INT NOT NULL,
`check_in_date` DATE NOT NULL,
`check_out_date` DATE NOT NULL,
`num_adults` INT NULL,
`num_children` INT NULL,
`customer_name` VARCHAR(45) NOT NULL,
`customer_email` VARCHAR(45) NOT NULL,
PRIMARY KEY (`reserve_id`, `customer_name`, `customer_email`),
INDEX `fk_reservation_customer1_idx` (`customer_name` ASC, `customer_email` ASC),
CONSTRAINT `fk_reservation_customer1`
FOREIGN KEY (`customer_name` , `customer_email`)
REFERENCES `mydb`.`customer` (`name` , `email`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`room`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`room` (
`room_number` INT NOT NULL,
`is_available` TINYINT NOT NULL,
`date` DATE NOT NULL,
`hotel_name` VARCHAR(45) NOT NULL,
`hotel_location_code` INT NOT NULL,
`room_information_info_id` INT NOT NULL,
`reservation_reserve_id` INT NOT NULL,
PRIMARY KEY (`room_number`, `date`, `hotel_name`, `hotel_location_code`),
INDEX `fk_room_hotel1_idx` (`hotel_name` ASC, `hotel_location_code` ASC),
INDEX `fk_room_room_information1_idx` (`room_information_info_id` ASC),
INDEX `fk_room_reservation1_idx` (`reservation_reserve_id` ASC),
CONSTRAINT `fk_room_hotel1`
FOREIGN KEY (`hotel_name` , `hotel_location_code`)
REFERENCES `mydb`.`hotel` (`name` , `location_code`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_room_room_information1`
FOREIGN KEY (`room_information_info_id`)
REFERENCES `mydb`.`room_information` (`info_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_room_reservation1`
FOREIGN KEY (`reservation_reserve_id`)
REFERENCES `mydb`.`reservation` (`reserve_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;
简单叙说 数据库逻辑模型 与 领域模型 的异同
异:数据库逻辑模型是面向实际的软件开发而建立的,他更加全面而明确地指定了存储数据的类型、键属性,便于直接根据数据库逻辑进行软件设计与开发;
领域模型则是一个商业建模范畴的概念,他和软件开发并无一丝一毫的关系,即使一个企业他不开发软件,他也具备他的业务模型,所有的同行业的企业他们的业务模型必定有非常大的共性和内在的规律性,由这个行业内的各个企业的业务模型再向上抽象出来整个行业的业务模型,就是领域模型,因此,领域模型主要是为了分析业务需求而建立的,他不需要明确指明数据的类型和属性,只需对业务实体进行建模。同:领域模型和数据库逻辑模型都是对业务实体进行图形可视化建模,都形象地展示了各个实体的名称、属性以及不同实体之间的联系。