1、 领域建模
-
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 模型(数据逻辑模型)
建模工具 PowerDesigner(简称PD) 或开源工具 OpenSystemArchitect
不负责的链接 http://www.cnblogs.com/mcgrady/archive/2013/05/25/3098588.html
导出 Mysql 物理数据库的脚本
-
-- MySQL Script generated by MySQL Workbench
-- Sun Apr 29 18:36:52 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`.`Traveller`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Traveller` (
`id` INT NOT NULL AUTO_INCREMENT,
`email` VARCHAR(45) NOT NULL,
`password` VARCHAR(45) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`CreditCard`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`CreditCard` (
`creditcard_id` INT NOT NULL AUTO_INCREMENT,
`traveller_id` INT NOT NULL,
`card_number` VARCHAR(45) NOT NULL,
PRIMARY KEY (`creditcard_id`, `traveller_id`),
INDEX `fk_CreditCard_Traveller1_idx` (`traveller_id` ASC),
CONSTRAINT `fk_CreditCard_Traveller1`
FOREIGN KEY (`traveller_id`)
REFERENCES `mydb`.`Traveller` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Destination`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Destination` (
`destination_id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
PRIMARY KEY (`destination_id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Hotel`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Hotel` (
`hotel_id` INT NOT NULL AUTO_INCREMENT,
`destination_id` INT NOT NULL,
`name` VARCHAR(45) NOT NULL,
PRIMARY KEY (`hotel_id`, `destination_id`),
INDEX `fk_Hotel_Destination1_idx` (`destination_id` ASC),
CONSTRAINT `fk_Hotel_Destination1`
FOREIGN KEY (`destination_id`)
REFERENCES `mydb`.`Destination` (`destination_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Room`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Room` (
`room_id` INT NOT NULL AUTO_INCREMENT,
`hotel_id` INT NOT NULL,
`price` DOUBLE NOT NULL,
PRIMARY KEY (`room_id`, `hotel_id`),
INDEX `fk_Room_Hotel_idx` (`hotel_id` ASC),
CONSTRAINT `fk_Room_Hotel`
FOREIGN KEY (`hotel_id`)
REFERENCES `mydb`.`Hotel` (`hotel_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Reservation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Reservation` (
`reservation_id` INT NOT NULL AUTO_INCREMENT,
`room_id` INT NOT NULL,
`hotel_id` INT NOT NULL,
`creditcard_id` INT NOT NULL,
`traveller_id` INT NOT NULL,
`checkin_time` DATETIME NOT NULL,
`checkout_time` DATETIME NOT NULL,
`table1col` VARCHAR(45) NULL,
PRIMARY KEY (`reservation_id`, `room_id`, `hotel_id`, `creditcard_id`, `traveller_id`),
INDEX `fk_Reservation_Room1_idx` (`room_id` ASC, `hotel_id` ASC),
INDEX `fk_Reservation_CreditCard1_idx` (`creditcard_id` ASC, `traveller_id` ASC),
CONSTRAINT `fk_Reservation_Room1`
FOREIGN KEY (`room_id` , `hotel_id`)
REFERENCES `mydb`.`Room` (`room_id` , `hotel_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Reservation_CreditCard1`
FOREIGN KEY (`creditcard_id` , `traveller_id`)
REFERENCES `mydb`.`CreditCard` (`creditcard_id` , `traveller_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;
- 简单叙说 数据库逻辑模型 与 领域模型 的异同
数据库逻辑模型与领域模型的相同之处是他们都是对一个系统的描述方法,不同之处是领域模型对系统的描述包括了数据以及其之间的操作方法与关系,而数据库逻辑模型需要考虑实体之间的主键或外键关联,比领域模型只考虑一对一还是一对多的关系