@zichuanyan
2018-04-29T23:44:58.000000Z
字数 3782
阅读 1046
系统分析与设计
领域建模
a. 阅读 Asg_RH 文档,按用例构建领域模型。
b. 数据库建模(E-R 模型)
-- MySQL Script generated by MySQL Workbench
-- 04/29/18 23:43:57
-- 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`.`room`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`room` (
`roomId` INT NOT NULL,
`type` VARCHAR(45) NULL,
`price` INT NULL,
`reservation` VARCHAR(45) NULL,
PRIMARY KEY (`roomId`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`reservation`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`reservation` (
`reservationId` INT NOT NULL,
`check in` DATE NULL,
`check out` DATE NULL,
`roomId` VARCHAR(45) NULL,
PRIMARY KEY (`reservationId`),
CONSTRAINT `roomId`
FOREIGN KEY ()
REFERENCES `mydb`.`room` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`Customer`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Customer` (
`CustomerId` INT NOT NULL,
`full name` VARCHAR(45) NOT NULL,
`email` VARCHAR(45) NULL,
PRIMARY KEY (`CustomerId`),
CONSTRAINT `reservationId`
FOREIGN KEY ()
REFERENCES `mydb`.`reservation` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
COMMENT = '\n';
-- -----------------------------------------------------
-- Table `mydb`.`Creditcard`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`Creditcard` (
`CreditcardId` INT NOT NULL,
`account` VARCHAR(45) NULL,
`orderpl` VARCHAR(45) NULL,
`password` CHAR(6) NULL,
`information` VARCHAR(45) NULL,
`Customer_CustomerId` INT NOT NULL,
PRIMARY KEY (`CreditcardId`, `Customer_CustomerId`),
INDEX `fk_Creditcard_Customer_idx` (`Customer_CustomerId` ASC),
CONSTRAINT `fk_Creditcard_Customer`
FOREIGN KEY (`Customer_CustomerId`)
REFERENCES `mydb`.`Customer` (`CustomerId`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `reservationId`
FOREIGN KEY ()
REFERENCES `mydb`.`reservation` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`hotel`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`hotel` (
`hotelId` INT NOT NULL,
`name` VARCHAR(45) NULL,
`location` VARCHAR(45) NULL,
`info` VARCHAR(45) NULL,
PRIMARY KEY (`hotelId`),
CONSTRAINT `roomId`
FOREIGN KEY ()
REFERENCES `mydb`.`room` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
USE `mydb` ;
-- -----------------------------------------------------
-- Placeholder table for view `mydb`.`view1`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`view1` (`id` INT);
-- -----------------------------------------------------
-- View `mydb`.`view1`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`view1`;
USE `mydb`;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;