Advertisement
Nikitalox

LR-6-create-tables

Jun 13th, 2024 (edited)
770
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 2.58 KB | None | 0 0
  1. -- MySQL Script generated by MySQL Workbench
  2. -- Thu Jun 13 16:17:35 2024
  3. -- Model: New Model    Version: 1.0
  4. -- MySQL Workbench Forward Engineering
  5.  
  6. SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
  7. SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
  8. SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
  9.  
  10. -- -----------------------------------------------------
  11. -- Schema hard_drive_db
  12. -- -----------------------------------------------------
  13.  
  14. -- -----------------------------------------------------
  15. -- Schema hard_drive_db
  16. -- -----------------------------------------------------
  17. CREATE SCHEMA IF NOT EXISTS `hard_drive_db` DEFAULT CHARACTER SET utf8 ;
  18. USE `hard_drive_db` ;
  19.  
  20. -- -----------------------------------------------------
  21. -- Table `hard_drive_db`.`serial_numbers`
  22. -- -----------------------------------------------------
  23. CREATE TABLE IF NOT EXISTS `hard_drive_db`.`serial_numbers` (
  24.   `serial_number` TINYTEXT NOT NULL,
  25.   `model` VARCHAR(255) NOT NULL,
  26.   PRIMARY KEY (`serial_number`),
  27.   UNIQUE INDEX `serial_number_UNIQUE` (`serial_number` ASC) VISIBLE)
  28. ENGINE = InnoDB;
  29.  
  30.  
  31. -- -----------------------------------------------------
  32. -- Table `hard_drive_db`.`producer`
  33. -- -----------------------------------------------------
  34. CREATE TABLE IF NOT EXISTS `hard_drive_db`.`producer` (
  35.   `name_producer` VARCHAR(255) NOT NULL,
  36.   `web-site` TINYTEXT NOT NULL,
  37.   PRIMARY KEY (`name_producer`))
  38. ENGINE = InnoDB;
  39.  
  40.  
  41. -- -----------------------------------------------------
  42. -- Table `hard_drive_db`.`characteristics`
  43. -- -----------------------------------------------------
  44. CREATE TABLE IF NOT EXISTS `hard_drive_db`.`characteristics` (
  45.   `model` VARCHAR(255) NOT NULL,
  46.   `name_producer` VARCHAR(255) NOT NULL,
  47.   `volume` VARCHAR(45) NOT NULL,
  48.   `rotation_speed` VARCHAR(45) NOT NULL,
  49.   `interface` VARCHAR(255) NULL,
  50.   INDEX `characteristics_to_sn_idx` (`model` ASC) VISIBLE,
  51.   INDEX `charesterictics_to_producer_idx` (`name_producer` ASC) VISIBLE,
  52.   CONSTRAINT `characteristics_to_sn`
  53.     FOREIGN KEY (`model`)
  54.     REFERENCES `hard_drive_db`.`serial_numbers` (`serial_number`)
  55.     ON DELETE CASCADE
  56.     ON UPDATE CASCADE,
  57.   CONSTRAINT `charesterictics_to_producer`
  58.     FOREIGN KEY (`name_producer`)
  59.     REFERENCES `hard_drive_db`.`producer` (`name_producer`)
  60.     ON DELETE CASCADE
  61.     ON UPDATE CASCADE)
  62. ENGINE = InnoDB;
  63.  
  64.  
  65. SET SQL_MODE=@OLD_SQL_MODE;
  66. SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  67. SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement