SHARE
TWEET

Untitled

a guest Nov 21st, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- MySQL Script generated by MySQL Workbench
  2. -- Thu Nov 21 15:43:53 2019
  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='TRADITIONAL,ALLOW_INVALID_DATES';
  9.  
  10. -- -----------------------------------------------------
  11. -- Schema eRecarga
  12. -- -----------------------------------------------------
  13.  
  14. -- -----------------------------------------------------
  15. -- Schema eRecarga
  16. -- -----------------------------------------------------
  17. CREATE SCHEMA IF NOT EXISTS `eRecarga` DEFAULT CHARACTER SET utf8 ;
  18. USE `eRecarga` ;
  19.  
  20. -- -----------------------------------------------------
  21. -- Table `eRecarga`.`utilizador`
  22. -- -----------------------------------------------------
  23. CREATE TABLE IF NOT EXISTS `eRecarga`.`utilizador` (
  24.   `idUtilizador` INT NOT NULL AUTO_INCREMENT,
  25.   `username` VARCHAR(45) NULL,
  26.   `password` VARCHAR(255) NULL,
  27.   PRIMARY KEY (`idUtilizador`),
  28.   UNIQUE INDEX `username_UNIQUE` (`username` ASC),
  29.   UNIQUE INDEX `password_UNIQUE` (`password` ASC))
  30. ENGINE = InnoDB;
  31.  
  32.  
  33. -- -----------------------------------------------------
  34. -- Table `eRecarga`.`distrito`
  35. -- -----------------------------------------------------
  36. CREATE TABLE IF NOT EXISTS `eRecarga`.`distrito` (
  37.   `idDistrito` INT NOT NULL AUTO_INCREMENT,
  38.   `nomeDistrito` VARCHAR(45) NULL,
  39.   PRIMARY KEY (`idDistrito`))
  40. ENGINE = InnoDB;
  41.  
  42.  
  43. -- -----------------------------------------------------
  44. -- Table `eRecarga`.`regiao`
  45. -- -----------------------------------------------------
  46. CREATE TABLE IF NOT EXISTS `eRecarga`.`regiao` (
  47.   `idRegiao` INT NOT NULL AUTO_INCREMENT,
  48.   `nomeRegiao` VARCHAR(100) NULL,
  49.   `idDistrito` INT NOT NULL,
  50.   PRIMARY KEY (`idRegiao`),
  51.   INDEX `fk_regiao_distrito1_idx` (`idDistrito` ASC),
  52.   CONSTRAINT `fk_regiao_distrito1`
  53.     FOREIGN KEY (`idDistrito`)
  54.     REFERENCES `eRecarga`.`distrito` (`idDistrito`)
  55.     ON DELETE NO ACTION
  56.     ON UPDATE NO ACTION)
  57. ENGINE = InnoDB;
  58.  
  59.  
  60. -- -----------------------------------------------------
  61. -- Table `eRecarga`.`posto`
  62. -- -----------------------------------------------------
  63. CREATE TABLE IF NOT EXISTS `eRecarga`.`posto` (
  64.   `idPosto` INT NOT NULL AUTO_INCREMENT,
  65.   `localizacao` VARCHAR(155) NULL,
  66.   `idRegiao` INT NOT NULL,
  67.   `precoCarregamento` DOUBLE NULL,
  68.   `longitude` DOUBLE NULL,
  69.   `latitude` DOUBLE NULL,
  70.   PRIMARY KEY (`idPosto`),
  71.   CONSTRAINT `fk_posto_regiao1`
  72.     FOREIGN KEY (`idRegiao`)
  73.     REFERENCES `eRecarga`.`regiao` (`idRegiao`)
  74.     ON DELETE NO ACTION
  75.     ON UPDATE NO ACTION)
  76. ENGINE = InnoDB;
  77.  
  78.  
  79. -- -----------------------------------------------------
  80. -- Table `eRecarga`.`reserva`
  81. -- -----------------------------------------------------
  82. CREATE TABLE IF NOT EXISTS `eRecarga`.`reserva` (
  83.   `idUtilizador` INT NOT NULL,
  84.   `idReserva` INT NOT NULL AUTO_INCREMENT,
  85.   `codServico` INT NULL,
  86.   `custoPrevisto` DOUBLE NULL,
  87.   `idPosto` INT NOT NULL,
  88.   `estado` VARCHAR(45) NULL,
  89.   `diaReserva` DATE NULL,
  90.   PRIMARY KEY (`idReserva`),
  91.   INDEX `fk_reserva_utilizador1_idx` (`idUtilizador` ASC),
  92.   INDEX `fk_reserva_posto1_idx` (`idPosto` ASC),
  93.   CONSTRAINT `fk_reserva_utilizador1`
  94.     FOREIGN KEY (`idUtilizador`)
  95.     REFERENCES `eRecarga`.`utilizador` (`idUtilizador`)
  96.     ON DELETE NO ACTION
  97.     ON UPDATE NO ACTION,
  98.   CONSTRAINT `fk_reserva_posto1`
  99.     FOREIGN KEY (`idPosto`)
  100.     REFERENCES `eRecarga`.`posto` (`idPosto`)
  101.     ON DELETE NO ACTION
  102.     ON UPDATE NO ACTION)
  103. ENGINE = InnoDB;
  104.  
  105.  
  106. -- -----------------------------------------------------
  107. -- Table `eRecarga`.`intervaloTempo`
  108. -- -----------------------------------------------------
  109. CREATE TABLE IF NOT EXISTS `eRecarga`.`intervaloTempo` (
  110.   `idIntervaloTempo` INT NOT NULL AUTO_INCREMENT,
  111.   `horaInicio` VARCHAR(45) NULL,
  112.   `horaFim` VARCHAR(45) NULL,
  113.   PRIMARY KEY (`idIntervaloTempo`))
  114. ENGINE = InnoDB;
  115.  
  116.  
  117. -- -----------------------------------------------------
  118. -- Table `eRecarga`.`disponibilidadesByTempo`
  119. -- -----------------------------------------------------
  120. CREATE TABLE IF NOT EXISTS `eRecarga`.`disponibilidadesByTempo` (
  121.   `idPosto` INT NOT NULL,
  122.   `idIntervaloTempo` INT NOT NULL,
  123.   `disponibilidade` TINYINT NULL,
  124.   INDEX `fk_posto_has_intervaloTempo_intervaloTempo1_idx` (`idIntervaloTempo` ASC),
  125.   INDEX `fk_posto_has_intervaloTempo_posto1_idx` (`idPosto` ASC),
  126.   CONSTRAINT `fk_posto_has_intervaloTempo_posto1`
  127.     FOREIGN KEY (`idPosto`)
  128.     REFERENCES `eRecarga`.`posto` (`idPosto`)
  129.     ON DELETE NO ACTION
  130.     ON UPDATE NO ACTION,
  131.   CONSTRAINT `fk_posto_has_intervaloTempo_intervaloTempo1`
  132.     FOREIGN KEY (`idIntervaloTempo`)
  133.     REFERENCES `eRecarga`.`intervaloTempo` (`idIntervaloTempo`)
  134.     ON DELETE NO ACTION
  135.     ON UPDATE NO ACTION)
  136. ENGINE = InnoDB;
  137.  
  138.  
  139. -- -----------------------------------------------------
  140. -- Table `eRecarga`.`itinerario`
  141. -- -----------------------------------------------------
  142. CREATE TABLE IF NOT EXISTS `eRecarga`.`itinerario` (
  143.   `iditinerario` INT NOT NULL,
  144.   `partida` VARCHAR(45) NULL,
  145.   `destino` VARCHAR(45) NULL,
  146.   PRIMARY KEY (`iditinerario`))
  147. ENGINE = InnoDB;
  148.  
  149.  
  150. SET SQL_MODE=@OLD_SQL_MODE;
  151. SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  152. SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top