1、 領(lǐng)域建模
-
a. 閱讀 Asg_RH 文檔岖圈,按用例構(gòu)建領(lǐng)域模型。
- 按 Task2 要求钙皮,請使用工具 UMLet蜂科,截圖格式務(wù)必是 png 并控制尺寸
- 說明:請不要受 PCMEF 層次結(jié)構(gòu)影響。你需要識別實體(E)和 中介實體(M短条,也稱狀態(tài)實體)
- 在單頁面應(yīng)用(如 vue)中导匣,E 一般與數(shù)據(jù)庫構(gòu)建有關(guān), M 一般與 store 模式 有關(guān)
-
在 java web 應(yīng)用中茸时,E 一般與數(shù)據(jù)庫構(gòu)建有關(guān)贡定, M 一般與 session 有關(guān)
-
b. 數(shù)據(jù)庫建模(E-R 模型)
-
按 Task 3 要求,給出系統(tǒng)的 E-R 模型(數(shù)據(jù)邏輯模型)
建模工具 PowerDesigner(簡稱PD) 或開源工具 OpenSystemArchitect
不負責的鏈接 http://www.cnblogs.com/mcgrady/archive/2013/05/25/3098588.html
導(dǎo)出 Mysql 物理數(shù)據(jù)庫的腳本
-
-- 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;
- 簡單敘說 數(shù)據(jù)庫邏輯模型 與 領(lǐng)域模型 的異同
數(shù)據(jù)庫邏輯模型與領(lǐng)域模型的相同之處是他們都是對一個系統(tǒng)的描述方法可都,不同之處是領(lǐng)域模型對系統(tǒng)的描述包括了數(shù)據(jù)以及其之間的操作方法與關(guān)系缓待,而數(shù)據(jù)庫邏輯模型需要考慮實體之間的主鍵或外鍵關(guān)聯(lián),比領(lǐng)域模型只考慮一對一還是一對多的關(guān)系