# data[].attributes.headline
Enunciado Sobre el Problema 4: Energia Electrica

# data[].attributes.subject
Enunciado Sobre el Problema 4: Energia Electrica

# data[].attributes.attachment_link.readable_text
-- MySQL Script generated by MySQL Workbench
-- Sun 28 Sep 2025 06:24:51 PM CST
-- 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='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

-- -----------------------------------------------------
-- Schema EnergiaElectrica
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema EnergiaElectrica
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `EnergiaElectrica` ;
SHOW WARNINGS;
USE `EnergiaElectrica` ;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`Compa��ia`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`Compa��ia` (
  `idCompa��ia` INT NOT NULL,
  `Nombre` VARCHAR(45) NULL,
  PRIMARY KEY (`idCompa��ia`))
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`Compra`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`Compra` (
  `idCompra` INT NOT NULL,
  `idTransportista` INT NOT NULL,
  `idSuministrador` INT NOT NULL,
  `idNuclear` INT NOT NULL,
  `Fecha` DATE NOT NULL,
  `Cantidad` DECIMAL NOT NULL,
  PRIMARY KEY (`idCompra`, `idTransportista`, `idSuministrador`, `idNuclear`),
  INDEX `fk_Compra_Transportista1_idx` (`idTransportista` ASC) VISIBLE,
  INDEX `fk_Compra_Suministrador1_idx` (`idSuministrador` ASC) VISIBLE,
  INDEX `fk_Compra_Nuclear1_idx` (`idNuclear` ASC) VISIBLE,
  CONSTRAINT `fk_Compra_Transportista1`
    FOREIGN KEY (`idTransportista`)
    REFERENCES `EnergiaElectrica`.`Transportista` (`idTransportista`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_Compra_Suministrador1`
    FOREIGN KEY (`idSuministrador`)
    REFERENCES `EnergiaElectrica`.`Suministrador` (`idSuministrador`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_Compra_Nuclear1`
    FOREIGN KEY (`idNuclear`)
    REFERENCES `EnergiaElectrica`.`Nuclear` (`idNuclear`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`Distribuye`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`Distribuye` (
  `idZona` INT NOT NULL,
  `idSubestacion` INT NOT NULL,
  PRIMARY KEY (`idZona`, `idSubestacion`),
  INDEX `fk_Zona_has_Subestacion_Subestacion1_idx` (`idSubestacion` ASC) VISIBLE,
  INDEX `fk_Zona_has_Subestacion_Zona1_idx` (`idZona` ASC) VISIBLE,
  CONSTRAINT `fk_Zona_has_Subestacion_Zona1`
    FOREIGN KEY (`idZona`)
    REFERENCES `EnergiaElectrica`.`Zona` (`idZona`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_Zona_has_Subestacion_Subestacion1`
    FOREIGN KEY (`idSubestacion`)
    REFERENCES `EnergiaElectrica`.`Subestacion` (`idSubestacion`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`Entrega`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`Entrega` (
  `idEstacionPrimaria` INT NOT NULL,
  `idProductor` INT NOT NULL,
  `Cantidad` INT NOT NULL,
  PRIMARY KEY (`idEstacionPrimaria`, `idProductor`),
  INDEX `fk_EstacionPrimaria_has_Productor_Productor1_idx` (`idProductor` ASC) VISIBLE,
  CONSTRAINT `fk_EstacionPrimaria_has_Productor_EstacionPrimaria1`
    FOREIGN KEY (`idEstacionPrimaria`)
    REFERENCES `EnergiaElectrica`.`EstacionPrimaria` (`idEstacionPrimaria`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_EstacionPrimaria_has_Productor_Productor1`
    FOREIGN KEY (`idProductor`)
    REFERENCES `EnergiaElectrica`.`Productor` (`idProductor`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`Envia_Energ`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`Envia_Energ` (
  `idRED_envio` INT NOT NULL,
  `Volumen` DECIMAL NOT NULL,
  `idRED_regreso` INT NOT NULL,
  PRIMARY KEY (`idRED_envio`, `idRED_regreso`),
  INDEX `fk_RED_has_RED_RED2_idx` (`idRED_regreso` ASC) VISIBLE,
  INDEX `fk_RED_has_RED_RED1_idx` (`idRED_envio` ASC) VISIBLE,
  CONSTRAINT `fk_RED_has_RED_RED1`
    FOREIGN KEY (`idRED_envio`)
    REFERENCES `EnergiaElectrica`.`RED` (`idRED`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_RED_has_RED_RED2`
    FOREIGN KEY (`idRED_regreso`)
    REFERENCES `EnergiaElectrica`.`RED` (`idRED`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`EstacionPrimaria`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`EstacionPrimaria` (
  `idEstacionPrimaria` INT NOT NULL,
  `Nombre` VARCHAR(45) NULL,
  `Transformadores` VARCHAR(45) NULL,
  PRIMARY KEY (`idEstacionPrimaria`))
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`Linea`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`Linea` (
  `idLinea` INT NOT NULL,
  `idRED` INT NOT NULL,
  `Longitud` INT NOT NULL,
  `No_Linea` INT NOT NULL,
  INDEX `fk_Linea_RED_idx` (`idRED` ASC) VISIBLE,
  PRIMARY KEY (`idLinea`, `idRED`),
  CONSTRAINT `fk_Linea_RED`
    FOREIGN KEY (`idRED`)
    REFERENCES `EnergiaElectrica`.`RED` (`idRED`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = big5;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`Nuclear`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`Nuclear` (
  `idNuclear` INT NOT NULL,
  `idProductor` INT NOT NULL,
  `Reactores` INT NOT NULL,
  `Plutonio_consu` DECIMAL NOT NULL,
  `Residuos` DECIMAL NOT NULL,
  PRIMARY KEY (`idNuclear`, `idProductor`),
  INDEX `fk_Nuclear_Productor1_idx` (`idProductor` ASC) VISIBLE,
  CONSTRAINT `fk_Nuclear_Productor1`
    FOREIGN KEY (`idProductor`)
    REFERENCES `EnergiaElectrica`.`Productor` (`idProductor`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`Pertenece`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`Pertenece` (
  `idRED` INT NOT NULL,
  `idCompa��ia` INT NOT NULL,
  PRIMARY KEY (`idRED`, `idCompa��ia`),
  INDEX `fk_RED_has_Compa��ia_Compa��ia1_idx` (`idCompa��ia` ASC) VISIBLE,
  INDEX `fk_RED_has_Compa��ia_RED1_idx` (`idRED` ASC) VISIBLE,
  CONSTRAINT `fk_RED_has_Compa��ia_RED1`
    FOREIGN KEY (`idRED`)
    REFERENCES `EnergiaElectrica`.`RED` (`idRED`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_RED_has_Compa��ia_Compa��ia1`
    FOREIGN KEY (`idCompa��ia`)
    REFERENCES `EnergiaElectrica`.`Compa��ia` (`idCompa��ia`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`Presa`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`Presa` (
  `idPresa` INT NOT NULL,
  `idProductor` INT NOT NULL,
  `Cap_Max` INT NOT NULL,
  `Ocupacion` INT NOT NULL,
  `No_Turbinas` INT NOT NULL,
  PRIMARY KEY (`idPresa`, `idProductor`),
  INDEX `fk_Presa_Productor1_idx` (`idProductor` ASC) VISIBLE,
  CONSTRAINT `fk_Presa_Productor1`
    FOREIGN KEY (`idProductor`)
    REFERENCES `EnergiaElectrica`.`Productor` (`idProductor`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`Productor`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`Productor` (
  `idProductor` INT NOT NULL,
  `Nombre` VARCHAR(45) NOT NULL,
  `Tipo_Produc` VARCHAR(45) NOT NULL,
  `Prod_Max` INT NOT NULL,
  `Prod_Min` INT NOT NULL,
  `F_Inicio` DATE NOT NULL,
  PRIMARY KEY (`idProductor`))
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`Provincia`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`Provincia` (
  `idProvincia` INT NOT NULL,
  `Nombre` VARCHAR(45) NULL,
  PRIMARY KEY (`idProvincia`))
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`RED`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`RED` (
  `idRED` INT NOT NULL,
  `RED` VARCHAR(45) NOT NULL,
  `idEstacionPrimaria` INT NOT NULL,
  PRIMARY KEY (`idRED`, `idEstacionPrimaria`),
  INDEX `fk_RED_EstacionPrimaria1_idx` (`idEstacionPrimaria` ASC) VISIBLE,
  CONSTRAINT `fk_RED_EstacionPrimaria1`
    FOREIGN KEY (`idEstacionPrimaria`)
    REFERENCES `EnergiaElectrica`.`EstacionPrimaria` (`idEstacionPrimaria`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`Solar`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`Solar` (
  `idSolar` INT NOT NULL,
  `idProductor` INT NOT NULL,
  `Superficie` FLOAT NOT NULL,
  `Tipo` VARCHAR(45) NOT NULL,
  `Horas_Sol` INT NOT NULL,
  PRIMARY KEY (`idSolar`, `idProductor`),
  INDEX `fk_Solar_Productor1_idx` (`idProductor` ASC) VISIBLE,
  CONSTRAINT `fk_Solar_Productor1`
    FOREIGN KEY (`idProductor`)
    REFERENCES `EnergiaElectrica`.`Productor` (`idProductor`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`Subestacion`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`Subestacion` (
  `idSubestacion` INT NOT NULL,
  `idLinea` INT NOT NULL,
  `idRED` INT NOT NULL,
  PRIMARY KEY (`idSubestacion`, `idLinea`, `idRED`),
  INDEX `fk_Subestacion_Linea1_idx` (`idLinea` ASC, `idRED` ASC) VISIBLE,
  CONSTRAINT `fk_Subestacion_Linea1`
    FOREIGN KEY (`idLinea` , `idRED`)
    REFERENCES `EnergiaElectrica`.`Linea` (`idLinea` , `idRED`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`Suministrador`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`Suministrador` (
  `idSuministrador` INT NOT NULL,
  `Nombre` VARCHAR(45) NOT NULL,
  `Pais` VARCHAR(20) NOT NULL,
  PRIMARY KEY (`idSuministrador`))
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`Termica`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`Termica` (
  `idTermica` INT NOT NULL,
  `idProductor` INT NOT NULL,
  `Hornos` INT NOT NULL,
  `Carbon_consu` DECIMAL NOT NULL,
  `Gases_emitid` DECIMAL NOT NULL,
  PRIMARY KEY (`idTermica`, `idProductor`),
  INDEX `fk_Termica_Productor1_idx` (`idProductor` ASC) VISIBLE,
  CONSTRAINT `fk_Termica_Productor1`
    FOREIGN KEY (`idProductor`)
    REFERENCES `EnergiaElectrica`.`Productor` (`idProductor`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`Transportista`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`Transportista` (
  `idTransportista` INT NOT NULL,
  `Nombre` VARCHAR(45) NOT NULL,
  `Matricula` INT NOT NULL,
  PRIMARY KEY (`idTransportista`))
ENGINE = InnoDB;

SHOW WARNINGS;

-- -----------------------------------------------------
-- Table `EnergiaElectrica`.`Zona`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `EnergiaElectrica`.`Zona` (
  `idZona` INT NOT NULL,
  `idProvincia` INT NOT NULL,
  `Consumo_Medio` INT NULL,
  `Consumidores` VARCHAR(45) NULL,
  PRIMARY KEY (`idZona`, `idProvincia`),
  INDEX `fk_Zona_Provincia1_idx` (`idProvincia` ASC) VISIBLE,
  CONSTRAINT `fk_Zona_Provincia1`
    FOREIGN KEY (`idProvincia`)
    REFERENCES `EnergiaElectrica`.`Provincia` (`idProvincia`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

SHOW WARNINGS;

SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;