-- MySQL Script generated by MySQL Workbench
-- Fri May  3 12:31:54 2024
-- 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 sistemadeinventario
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema sistemadeinventario
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `sistemadeinventario` DEFAULT CHARACTER SET utf8 ;
USE `sistemadeinventario` ;

-- -----------------------------------------------------
-- Table `sistemadeinventario`.`departamento`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sistemadeinventario`.`departamento` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `nombre` VARCHAR(20) NULL,
  `anaquel` VARCHAR(15) NULL,
  `status` INT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `sistemadeinventario`.`tipo`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sistemadeinventario`.`tipo` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `nombre` VARCHAR(20) NULL,
  `status` INT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `sistemadeinventario`.`marca`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sistemadeinventario`.`marca` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `nombre` VARCHAR(20) NULL,
  `status` INT NULL,
  `rutafoto` VARCHAR(100) NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `sistemadeinventario`.`pais`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sistemadeinventario`.`pais` (
  `id` INT NOT NULL,
  `nombre` VARCHAR(45) NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `sistemadeinventario`.`estado`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sistemadeinventario`.`estado` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `nombre` VARCHAR(45) NULL,
  `pais_idpais` INT NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_estado_pais1_idx` (`pais_idpais` ASC) VISIBLE,
  CONSTRAINT `fk_estado_pais1`
    FOREIGN KEY (`pais_idpais`)
    REFERENCES `sistemadeinventario`.`pais` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `sistemadeinventario`.`provedor`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sistemadeinventario`.`provedor` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `nombre` VARCHAR(20) NULL,
  `direccion` VARCHAR(20) NULL,
  `correo` VARCHAR(15) NULL,
  `telefono` VARCHAR(10) NULL,
  `status` INT NULL,
  `estado_idestado` INT NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_provedor_estado1_idx` (`estado_idestado` ASC) VISIBLE,
  CONSTRAINT `fk_provedor_estado1`
    FOREIGN KEY (`estado_idestado`)
    REFERENCES `sistemadeinventario`.`estado` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `sistemadeinventario`.`producto`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sistemadeinventario`.`producto` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `cantidad` VARCHAR(10) NULL,
  `nombre` VARCHAR(20) NULL,
  `precio` INT NULL,
  `codigoBarras` VARCHAR(15) NULL,
  `medida` INT NULL,
  `lote` VARCHAR(10) NULL,
  `departamento_id` INT NOT NULL,
  `tipo_idtipo` INT NOT NULL,
  `marca_idmarca` INT NOT NULL,
  `provedor_idprovedor` INT NOT NULL,
  `status` INT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_producto_departamento_idx` (`departamento_id` ASC) VISIBLE,
  INDEX `fk_producto_tipo1_idx` (`tipo_idtipo` ASC) VISIBLE,
  INDEX `fk_producto_marca1_idx` (`marca_idmarca` ASC) VISIBLE,
  INDEX `fk_producto_provedor1_idx` (`provedor_idprovedor` ASC) VISIBLE,
  CONSTRAINT `fk_producto_departamento`
    FOREIGN KEY (`departamento_id`)
    REFERENCES `sistemadeinventario`.`departamento` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_producto_tipo1`
    FOREIGN KEY (`tipo_idtipo`)
    REFERENCES `sistemadeinventario`.`tipo` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_producto_marca1`
    FOREIGN KEY (`marca_idmarca`)
    REFERENCES `sistemadeinventario`.`marca` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_producto_provedor1`
    FOREIGN KEY (`provedor_idprovedor`)
    REFERENCES `sistemadeinventario`.`provedor` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `sistemadeinventario`.`rol`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sistemadeinventario`.`rol` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `nombre` VARCHAR(20) NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `sistemadeinventario`.`usuario`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `sistemadeinventario`.`usuario` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `nombre` VARCHAR(45) NULL,
  `sexo` CHAR NULL,
  `telefono` VARCHAR(10) NULL,
  `correo` VARCHAR(20) NULL,
  `direccion` VARCHAR(40) NULL,
  `status` INT NULL,
  `npila` VARCHAR(15) NULL,
  `username` VARCHAR(20) NULL,
  `rutafoto` VARCHAR(100) NULL,
  `rol_idrol` INT NOT NULL,
  `estado_idestado` INT NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_usuario_rol1_idx` (`rol_idrol` ASC) VISIBLE,
  INDEX `fk_usuario_estado1_idx` (`estado_idestado` ASC) VISIBLE,
  CONSTRAINT `fk_usuario_rol1`
    FOREIGN KEY (`rol_idrol`)
    REFERENCES `sistemadeinventario`.`rol` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_usuario_estado1`
    FOREIGN KEY (`estado_idestado`)
    REFERENCES `sistemadeinventario`.`estado` (`id`)
    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;
