LaCaraDeLaVerga

Untitled

Sep 22nd, 2020
1,131
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- MySQL Workbench Forward Engineering
  2.  
  3. SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
  4. SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
  5. 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';
  6.  
  7. -- -----------------------------------------------------
  8. -- Schema Agenda
  9. -- -----------------------------------------------------
  10.  
  11. -- -----------------------------------------------------
  12. -- Schema Agenda
  13. -- -----------------------------------------------------
  14. CREATE SCHEMA IF NOT EXISTS `Agenda` ;
  15. USE `Agenda` ;
  16.  
  17. -- -----------------------------------------------------
  18. -- Table `Agenda`.`personas`
  19. -- -----------------------------------------------------
  20. CREATE TABLE IF NOT EXISTS `Agenda`.`personas` (
  21.   `idpersonas` INT NOT NULL AUTO_INCREMENT,
  22.   `nombre` VARCHAR(45) NOT NULL,
  23.   `telefono` VARCHAR(45) NOT NULL,
  24.   `email` VARCHAR(45) NULL,
  25.   `calle` VARCHAR(45) NULL,
  26.   `altura` INT NULL,
  27.   `piso` INT NULL,
  28.   `depto` VARCHAR(45) NULL,
  29.   `linkedin` VARCHAR(45) NULL,
  30.   `birthday` DATE NULL,
  31.   `idTipo` VARCHAR(45) NOT NULL,
  32.   PRIMARY KEY (`idpersonas`))
  33. ENGINE = InnoDB;
  34.  
  35.  
  36. -- -----------------------------------------------------
  37. -- Table `Agenda`.`tipo`
  38. -- -----------------------------------------------------
  39. CREATE TABLE IF NOT EXISTS `Agenda`.`tipo` (
  40.   `idtipo` INT NOT NULL AUTO_INCREMENT,
  41.   `nombre` VARCHAR(45) NOT NULL,
  42.   `idpersonas` INT NOT NULL,
  43.   PRIMARY KEY (`idtipo`),
  44.   INDEX `idPersona_idx` (`idpersonas` ASC) VISIBLE,
  45.   CONSTRAINT `idPersona`
  46.     FOREIGN KEY (`idpersonas`)
  47.     REFERENCES `Agenda`.`personas` (`idpersonas`)
  48.     ON DELETE NO ACTION
  49.     ON UPDATE NO ACTION)
  50. ENGINE = InnoDB;
  51.  
  52.  
  53. -- -----------------------------------------------------
  54. -- Table `Agenda`.`localidad`
  55. -- -----------------------------------------------------
  56. CREATE TABLE IF NOT EXISTS `Agenda`.`localidad` (
  57.   `idlocalidad` INT NOT NULL AUTO_INCREMENT,
  58.   `CP` INT NOT NULL,
  59.   `nombre` VARCHAR(45) NOT NULL,
  60.   `idpersonas` INT NOT NULL,
  61.   PRIMARY KEY (`idlocalidad`),
  62.   INDEX `idPersonas_idx` (`idpersonas` ASC) VISIBLE,
  63.   CONSTRAINT `idPersonas`
  64.     FOREIGN KEY (`idpersonas`)
  65.     REFERENCES `Agenda`.`personas` (`idpersonas`)
  66.     ON DELETE NO ACTION
  67.     ON UPDATE NO ACTION)
  68. ENGINE = InnoDB;
  69.  
  70.  
  71. -- -----------------------------------------------------
  72. -- Table `Agenda`.`provincia`
  73. -- -----------------------------------------------------
  74. CREATE TABLE IF NOT EXISTS `Agenda`.`provincia` (
  75.   `idprovincia` INT NOT NULL AUTO_INCREMENT,
  76.   `nombre` VARCHAR(45) NOT NULL,
  77.   `idlocalidad` INT NOT NULL,
  78.   PRIMARY KEY (`idprovincia`),
  79.   INDEX `idlocalidad_idx` (`idlocalidad` ASC) VISIBLE,
  80.   CONSTRAINT `idlocalidad`
  81.     FOREIGN KEY (`idlocalidad`)
  82.     REFERENCES `Agenda`.`localidad` (`idlocalidad`)
  83.     ON DELETE NO ACTION
  84.     ON UPDATE NO ACTION)
  85. ENGINE = InnoDB;
  86.  
  87.  
  88. -- -----------------------------------------------------
  89. -- Table `Agenda`.`pais`
  90. -- -----------------------------------------------------
  91. CREATE TABLE IF NOT EXISTS `Agenda`.`pais` (
  92.   `idpais` INT NOT NULL AUTO_INCREMENT,
  93.   `nombre` VARCHAR(45) NOT NULL,
  94.   `idprovincia` INT NOT NULL,
  95.   PRIMARY KEY (`idpais`),
  96.   INDEX `idprovincia_idx` (`idprovincia` ASC) VISIBLE,
  97.   CONSTRAINT `idprovincia`
  98.     FOREIGN KEY (`idprovincia`)
  99.     REFERENCES `Agenda`.`provincia` (`idprovincia`)
  100.     ON DELETE NO ACTION
  101.     ON UPDATE NO ACTION)
  102. ENGINE = InnoDB;
  103.  
  104.  
  105. SET SQL_MODE=@OLD_SQL_MODE;
  106. SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  107. SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  108.  
RAW Paste Data