系统分析与设计HW5
1、 领域建模
a. 阅读 Asg_RH 文档,按用例构建领域模型。
按 Task2 要求,请使用工具 UMLet,截图格式务必是 png 并控制尺寸
b. 数据库建模(E-R 模型)
按 Task 3 要求,给出系统的 E-R 模型(数据逻辑模型)
使用工具MYSQLWorkbanch来进行绘制。
数据库脚本
-- MySQL Script generated by MySQL Workbench
-- Thu Apr 26 17:37:27 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`.`hotel`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`hotel` ;
CREATE TABLE IF NOT EXISTS `mydb`.`hotel` (
`room_type` VARCHAR(45) NOT NULL,
`hotel_name` LONGTEXT NULL,
`room_state` TINYINT NULL,
PRIMARY KEY (`room_type`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`custmoer`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`custmoer` ;
CREATE TABLE IF NOT EXISTS `mydb`.`custmoer` (
`email` LONGTEXT NOT NULL,
`full_name` LONGTEXT NULL,
`spec_info` LONGTEXT NULL,
`somking` TINYINT NULL,
PRIMARY KEY (`email`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`order_room`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`order_room` ;
CREATE TABLE IF NOT EXISTS `mydb`.`order_room` (
`hotel_name` LONGTEXT NOT NULL,
`data` DATE NULL,
`email` LONGTEXT NULL,
`city` LONGTEXT NULL,
PRIMARY KEY (`hotel_name`),
CONSTRAINT `hotel_name`
FOREIGN KEY ()
REFERENCES `mydb`.`hotel` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `email`
FOREIGN KEY ()
REFERENCES `mydb`.`custmoer` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`crad`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`crad` ;
CREATE TABLE IF NOT EXISTS `mydb`.`crad` (
`card_num` VARCHAR(45) NULL,
`security_code` VARCHAR(45) NULL,
`expiry_data` DATE NULL,
`email` LONGTEXT NOT NULL,
PRIMARY KEY (`email`),
CONSTRAINT `email`
FOREIGN KEY ()
REFERENCES `mydb`.`custmoer` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`card_details`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`card_details` ;
CREATE TABLE IF NOT EXISTS `mydb`.`card_details` (
`email` LONGTEXT NOT NULL,
`first_name` VARCHAR(45) NULL,
`last_name` VARCHAR(45) NULL,
`address1` LONGTEXT NULL,
`address2` LONGTEXT NULL,
`state` VARCHAR(45) NULL,
`country` VARCHAR(45) NULL,
`post_code` LONGTEXT NULL,
`datatime_tel` LONGTEXT NULL,
`evening_tel` LONGTEXT NULL,
PRIMARY KEY (`email`),
CONSTRAINT `email`
FOREIGN KEY ()
REFERENCES `mydb`.`crad` ()
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;
简单叙说数据库逻辑模型与领域模型的异同
相同点:都描述了数据实体的属性以及它们之间的关系。
不同点:临域模型中不会排除不需要存储相关信息的类,数据库逻辑模型中排除了不要存储信息的类。