text: -- MySQL Script generated by Federico Arambillet
  -- Fri Jan 15 19:03:14 2021
  -- 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='TRADITIONAL,ALLOW_INVALID_DATES';
  
  -- -----------------------------------------------------
  -- Schema articulos_del_hogar
  -- -----------------------------------------------------
  
  -- -----------------------------------------------------
  -- Schema articulos_del_hogar
  -- -----------------------------------------------------
  CREATE SCHEMA IF NOT EXISTS `articulos_del_hogar` DEFAULT CHARACTER SET utf8 ;
  USE `articulos_del_hogar` ;
  
  -- -----------------------------------------------------
  -- Table `articulos_del_hogar`.`USUARIO`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `articulos_del_hogar`.`USUARIO` (
    `idUsuario` INT NOT NULL AUTO_INCREMENT,
    `email` VARCHAR(45) NOT NULL,
    `password` VARCHAR(45) NOT NULL,
    `direccion` VARCHAR(45) NULL,
    `ciudad` VARCHAR(45) NULL,
    `esAdmin` TINYINT NOT NULL,
    PRIMARY KEY (`idUsuario`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `articulos_del_hogar`.`CATEGORIA`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `articulos_del_hogar`.`CATEGORIA` (
    `idCategoria` INT NOT NULL AUTO_INCREMENT,
    `nombre` VARCHAR(45) NOT NULL,
    PRIMARY KEY (`idCategoria`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `articulos_del_hogar`.`ARTICULO`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `articulos_del_hogar`.`ARTICULO` (
    `idArticulo` INT NOT NULL AUTO_INCREMENT,
    `nombre` VARCHAR(60) NOT NULL,
    `precio` FLOAT NOT NULL,
    `financiacion` VARCHAR(45) NOT NULL,
    `detalle` VARCHAR(400) NOT NULL,
    `tipo` VARCHAR(45) NOT NULL,
    `stock` INT NOT NULL,
    `idCategoria` INT NOT NULL,
    PRIMARY KEY (`idArticulo`),
    INDEX `fk_ARTICULO_CATEGORIA1_idx` (`idCategoria` ASC),
    CONSTRAINT `fk_ARTICULO_CATEGORIA1`
      FOREIGN KEY (`idCategoria`)
      REFERENCES `articulos_del_hogar`.`CATEGORIA` (`idCategoria`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `articulos_del_hogar`.`LOCAL`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `articulos_del_hogar`.`LOCAL` (
    `idLocal` INT NOT NULL AUTO_INCREMENT,
    `cuit` VARCHAR(45) NOT NULL,
    `nombre` VARCHAR(45) NOT NULL,
    `direccion` VARCHAR(45) NOT NULL,
    `codigo_area` INT NOT NULL,
    `nro_telefono` INT NOT NULL,
    PRIMARY KEY (`idLocal`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `articulos_del_hogar`.`FACTURA`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `articulos_del_hogar`.`FACTURA` (
    `idFactura` INT NOT NULL AUTO_INCREMENT,
    `fecha` DATE NOT NULL,
    `total` FLOAT NOT NULL,
    `idLocal` INT NOT NULL,
    `idUsuario` INT NOT NULL,
    PRIMARY KEY (`idFactura`),
    INDEX `fk_FACTURA_LOCAL1_idx` (`idLocal` ASC),
    INDEX `fk_FACTURA_USUARIO1_idx` (`idUsuario` ASC),
    CONSTRAINT `fk_FACTURA_LOCAL1`
      FOREIGN KEY (`idLocal`)
      REFERENCES `articulos_del_hogar`.`LOCAL` (`idLocal`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_FACTURA_USUARIO1`
      FOREIGN KEY (`idUsuario`)
      REFERENCES `articulos_del_hogar`.`USUARIO` (`idUsuario`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `articulos_del_hogar`.`DETALLE_FACTURA`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `articulos_del_hogar`.`DETALLE_FACTURA` (
    `idDetalle` INT NOT NULL AUTO_INCREMENT,
    `cantidad` INT NOT NULL,
    `idArticulo` INT NOT NULL,
    `idFactura` INT NOT NULL,
    PRIMARY KEY (`idDetalle`),
    INDEX `fk_DETALLE_FACTURA_ARTICULO1_idx` (`idArticulo` ASC),
    INDEX `fk_DETALLE_FACTURA_FACTURA1_idx` (`idFactura` ASC),
    CONSTRAINT `fk_DETALLE_FACTURA_ARTICULO1`
      FOREIGN KEY (`idArticulo`)
      REFERENCES `articulos_del_hogar`.`ARTICULO` (`idArticulo`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_DETALLE_FACTURA_FACTURA1`
      FOREIGN KEY (`idFactura`)
      REFERENCES `articulos_del_hogar`.`FACTURA` (`idFactura`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `articulos_del_hogar`.`IMAGEN_ARTICULO`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `articulos_del_hogar`.`IMAGEN_ARTICULO` (
    `idImagen` INT NOT NULL AUTO_INCREMENT,
    `imagen` VARCHAR(200) NOT NULL,
    `principal` TINYINT NOT NULL,
    `idArticulo` INT NOT NULL,
    PRIMARY KEY (`idImagen`),
    INDEX `fk_IMAGEN_ARTICULO_ARTICULO1_idx` (`idArticulo` ASC),
    CONSTRAINT `fk_IMAGEN_ARTICULO_ARTICULO1`
      FOREIGN KEY (`idArticulo`)
      REFERENCES `articulos_del_hogar`.`ARTICULO` (`idArticulo`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
   
  -- -----------------------------------------------------
  -- Table `articulos_del_hogar`.`CARRITO`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `articulos_del_hogar`.`CARRITO` (
    `idCarrito` INT NOT NULL AUTO_INCREMENT,
    `cantidad` INT NOT NULL,
    `idArticulo` INT NOT NULL,
    `idUsuario` INT NOT NULL,
    PRIMARY KEY (`idCarrito`),
    INDEX `fk_CARRITO_USUARIO1_idx` (`idUsuario` ASC),
    INDEX `fk_CARRITO_ARTICULO1_idx` (`idArticulo` ASC),
    CONSTRAINT `fk_CARRITO_USUARIO1`
      FOREIGN KEY (`idUsuario`)
      REFERENCES `articulos_del_hogar`.`USUARIO` (`idUsuario`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_CARRITO_ARTICULO1`
      FOREIGN KEY (`idArticulo`)
      REFERENCES `articulos_del_hogar`.`ARTICULO` (`idArticulo`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  
  SET SQL_MODE=@OLD_SQL_MODE;
  SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  