[关闭]
@zichuanyan 2018-04-29T23:44:58.000000Z 字数 3782 阅读 1046

作业五

系统分析与设计 领域建模


  1. -- MySQL Script generated by MySQL Workbench
  2. -- 04/29/18 23:43:57
  3. -- Model: New Model Version: 1.0
  4. -- MySQL Workbench Forward Engineering
  5. SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
  6. SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
  7. SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
  8. -- -----------------------------------------------------
  9. -- Schema mydb
  10. -- -----------------------------------------------------
  11. -- -----------------------------------------------------
  12. -- Schema mydb
  13. -- -----------------------------------------------------
  14. CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;
  15. USE `mydb` ;
  16. -- -----------------------------------------------------
  17. -- Table `mydb`.`room`
  18. -- -----------------------------------------------------
  19. CREATE TABLE IF NOT EXISTS `mydb`.`room` (
  20. `roomId` INT NOT NULL,
  21. `type` VARCHAR(45) NULL,
  22. `price` INT NULL,
  23. `reservation` VARCHAR(45) NULL,
  24. PRIMARY KEY (`roomId`))
  25. ENGINE = InnoDB;
  26. -- -----------------------------------------------------
  27. -- Table `mydb`.`reservation`
  28. -- -----------------------------------------------------
  29. CREATE TABLE IF NOT EXISTS `mydb`.`reservation` (
  30. `reservationId` INT NOT NULL,
  31. `check in` DATE NULL,
  32. `check out` DATE NULL,
  33. `roomId` VARCHAR(45) NULL,
  34. PRIMARY KEY (`reservationId`),
  35. CONSTRAINT `roomId`
  36. FOREIGN KEY ()
  37. REFERENCES `mydb`.`room` ()
  38. ON DELETE NO ACTION
  39. ON UPDATE NO ACTION)
  40. ENGINE = InnoDB;
  41. -- -----------------------------------------------------
  42. -- Table `mydb`.`Customer`
  43. -- -----------------------------------------------------
  44. CREATE TABLE IF NOT EXISTS `mydb`.`Customer` (
  45. `CustomerId` INT NOT NULL,
  46. `full name` VARCHAR(45) NOT NULL,
  47. `email` VARCHAR(45) NULL,
  48. PRIMARY KEY (`CustomerId`),
  49. CONSTRAINT `reservationId`
  50. FOREIGN KEY ()
  51. REFERENCES `mydb`.`reservation` ()
  52. ON DELETE NO ACTION
  53. ON UPDATE NO ACTION)
  54. ENGINE = InnoDB
  55. COMMENT = '\n';
  56. -- -----------------------------------------------------
  57. -- Table `mydb`.`Creditcard`
  58. -- -----------------------------------------------------
  59. CREATE TABLE IF NOT EXISTS `mydb`.`Creditcard` (
  60. `CreditcardId` INT NOT NULL,
  61. `account` VARCHAR(45) NULL,
  62. `orderpl` VARCHAR(45) NULL,
  63. `password` CHAR(6) NULL,
  64. `information` VARCHAR(45) NULL,
  65. `Customer_CustomerId` INT NOT NULL,
  66. PRIMARY KEY (`CreditcardId`, `Customer_CustomerId`),
  67. INDEX `fk_Creditcard_Customer_idx` (`Customer_CustomerId` ASC),
  68. CONSTRAINT `fk_Creditcard_Customer`
  69. FOREIGN KEY (`Customer_CustomerId`)
  70. REFERENCES `mydb`.`Customer` (`CustomerId`)
  71. ON DELETE NO ACTION
  72. ON UPDATE NO ACTION,
  73. CONSTRAINT `reservationId`
  74. FOREIGN KEY ()
  75. REFERENCES `mydb`.`reservation` ()
  76. ON DELETE NO ACTION
  77. ON UPDATE NO ACTION)
  78. ENGINE = InnoDB;
  79. -- -----------------------------------------------------
  80. -- Table `mydb`.`hotel`
  81. -- -----------------------------------------------------
  82. CREATE TABLE IF NOT EXISTS `mydb`.`hotel` (
  83. `hotelId` INT NOT NULL,
  84. `name` VARCHAR(45) NULL,
  85. `location` VARCHAR(45) NULL,
  86. `info` VARCHAR(45) NULL,
  87. PRIMARY KEY (`hotelId`),
  88. CONSTRAINT `roomId`
  89. FOREIGN KEY ()
  90. REFERENCES `mydb`.`room` ()
  91. ON DELETE NO ACTION
  92. ON UPDATE NO ACTION)
  93. ENGINE = InnoDB;
  94. USE `mydb` ;
  95. -- -----------------------------------------------------
  96. -- Placeholder table for view `mydb`.`view1`
  97. -- -----------------------------------------------------
  98. CREATE TABLE IF NOT EXISTS `mydb`.`view1` (`id` INT);
  99. -- -----------------------------------------------------
  100. -- View `mydb`.`view1`
  101. -- -----------------------------------------------------
  102. DROP TABLE IF EXISTS `mydb`.`view1`;
  103. USE `mydb`;
  104. SET SQL_MODE=@OLD_SQL_MODE;
  105. SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  106. SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注