-- MySQL Script generated by MySQL Workbench
-- Fri Sep 20 00:12:29 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 mydb
-- -----------------------------------------------------

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

-- -----------------------------------------------------
-- Table `mydb`.`tipo_documento`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`tipo_documento` (
  `tp_cdgo` INT NOT NULL AUTO_INCREMENT,
  `tp_dscrpcion` VARCHAR(45) NOT NULL,
  `tp_estdo` BIT NOT NULL,
  PRIMARY KEY (`tp_cdgo`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`estado_solicitud`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`estado_solicitud` (
  `es_cdgo` INT NOT NULL AUTO_INCREMENT,
  `es_dscrpcion` VARCHAR(45) NOT NULL,
  `es_estdo` BIT NOT NULL,
  PRIMARY KEY (`es_cdgo`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`perfil`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`perfil` (
  `pf_cdgo` INT NOT NULL AUTO_INCREMENT,
  `pf_dscrption` VARCHAR(45) NOT NULL,
  `pf_estad` BIT NOT NULL,
  PRIMARY KEY (`pf_cdgo`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`vendedor`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`vendedor` (
  `vd_cdla` VARCHAR(45) NOT NULL,
  `vd_cdgo_rfrdo` INT NULL,
  `vd_tipo_documento_cdgo` INT NOT NULL,
  `vd_perfil_cdgo` INT NOT NULL,
  `vd_nmbre_cmplto` VARCHAR(45) NOT NULL,
  `vd_fcha_cmbio_clve` VARCHAR(45) NOT NULL,
  `vd_clve_1` VARCHAR(45) NOT NULL,
  `vd_clve_2` VARCHAR(45) NULL,
  `vd_clve_3` VARCHAR(45) NULL,
  `vd_clve_4` VARCHAR(45) NULL,
  `vd_clve_5` VARCHAR(45) NULL,
  `vd_clve_dnmca` VARCHAR(45) NULL,
  `vd_sldo` INT NOT NULL,
  `vd_cmbiar_clve` BIT NOT NULL,
  `vd_blqdo` BIT NOT NULL,
  `vd_cntdad_intnto` TINYINT NOT NULL,
  `vd_mail` VARCHAR(45) NOT NULL,
  `vd_estdo` BIT NOT NULL,
  `vd_fue_rfrdo` BIT NOT NULL,
  `vd_prcntje_rfrdo` FLOAT NULL,
  `vd_quien_rfrio_vendedor_cdla` VARCHAR(45) NULL,
  `vd_cntd_mxma_tqte` INT NOT NULL,
  `vd_prcntje_cmsion` FLOAT NULL,
  `vd_tken_scrty` VARCHAR(300) NULL,
  `vd_fcha_exprcion_tken` DATETIME NULL,
  PRIMARY KEY (`vd_cdla`),
  INDEX `fk_vendedor_tipo_documento1_idx` (`vd_tipo_documento_cdgo` ASC) VISIBLE,
  INDEX `fk_vendedor_perfil1_idx` (`vd_perfil_cdgo` ASC) VISIBLE,
  INDEX `fk_vendedor_vendedor1_idx` (`vd_quien_rfrio_vendedor_cdla` ASC) VISIBLE,
  CONSTRAINT `fk_vendedor_tipo_documento1`
    FOREIGN KEY (`vd_tipo_documento_cdgo`)
    REFERENCES `mydb`.`tipo_documento` (`tp_cdgo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_vendedor_perfil1`
    FOREIGN KEY (`vd_perfil_cdgo`)
    REFERENCES `mydb`.`perfil` (`pf_cdgo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_vendedor_vendedor1`
    FOREIGN KEY (`vd_quien_rfrio_vendedor_cdla`)
    REFERENCES `mydb`.`vendedor` (`vd_cdla`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`usuario`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`usuario` (
  `us_cdla` VARCHAR(45) NOT NULL,
  `us_tipo_documento_cdgo` INT NOT NULL,
  `us_perfil_cdgo` INT NOT NULL,
  `us_nmbre_cmplto` VARCHAR(45) NOT NULL,
  `us_fcha_cmbio_clve` VARCHAR(45) NULL,
  `us_clve_1` VARCHAR(45) NOT NULL,
  `us_clve_2` VARCHAR(45) NULL,
  `us_clve_3` VARCHAR(45) NULL,
  `us_clve_4` VARCHAR(45) NULL,
  `us_clve_5` VARCHAR(45) NULL,
  `us_clve_dnmca` INT NULL,
  `us_sldo` INT NOT NULL,
  `us_umbral_sldo` INT NULL,
  `us_cmbiar_clve` BIT NOT NULL,
  `us_blqdo` BIT NOT NULL,
  `us_cntdad_intnto` TINYINT NOT NULL,
  `us_mail` VARCHAR(45) NOT NULL,
  `us_estado_solicitud_cdgo` INT NOT NULL,
  `us_estdo` BIT NOT NULL,
  `us_fue_rfrdo` BIT NOT NULL,
  `us_prcntje_rfrdo` FLOAT NULL,
  `us_quien_rfrio_vendedor_cdla` VARCHAR(45) NULL,
  `us_tken_scrty` VARCHAR(300) NULL,
  `us_fcha_exprcion_tken` DATETIME NULL,
  PRIMARY KEY (`us_cdla`),
  INDEX `fk_usuario_tipo_documento_idx` (`us_tipo_documento_cdgo` ASC) VISIBLE,
  INDEX `fk_usuario_estado_solicitud1_idx` (`us_estado_solicitud_cdgo` ASC) VISIBLE,
  INDEX `fk_usuario_perfil1_idx` (`us_perfil_cdgo` ASC) VISIBLE,
  INDEX `fk_usuario_vendedor1_idx` (`us_quien_rfrio_vendedor_cdla` ASC) VISIBLE,
  CONSTRAINT `fk_usuario_tipo_documento`
    FOREIGN KEY (`us_tipo_documento_cdgo`)
    REFERENCES `mydb`.`tipo_documento` (`tp_cdgo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_usuario_estado_solicitud1`
    FOREIGN KEY (`us_estado_solicitud_cdgo`)
    REFERENCES `mydb`.`estado_solicitud` (`es_cdgo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_usuario_perfil1`
    FOREIGN KEY (`us_perfil_cdgo`)
    REFERENCES `mydb`.`perfil` (`pf_cdgo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_usuario_vendedor1`
    FOREIGN KEY (`us_quien_rfrio_vendedor_cdla`)
    REFERENCES `mydb`.`vendedor` (`vd_cdla`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`parametro_sistema`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`parametro_sistema` (
  `ps_cdgo` INT NOT NULL AUTO_INCREMENT,
  `ps_nmbre_aplccion` VARCHAR(75) NOT NULL,
  `ps_usrio_cntdad_intnto` INT NOT NULL,
  `ps_usrio_rcrga_mxma` INT NOT NULL,
  `ps_usrio_cntdad_crear` VARCHAR(45) NOT NULL,
  `ps_usrio_dble_fctor_autntccion` BIT NOT NULL,
  `ps_bloqueo_app` BIT NOT NULL,
  PRIMARY KEY (`ps_cdgo`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`juego`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`juego` (
  `jg_cdgo` INT NOT NULL AUTO_INCREMENT,
  `jg_nmbre_cmrcial` VARCHAR(45) NOT NULL,
  `jg_dscrpcion_fgra` VARCHAR(45) NULL,
  `jg_vlor` INT NOT NULL,
  `jg_vlor_dscrpcion` VARCHAR(45) NOT NULL,
  `jg_enncdo` VARCHAR(45) NOT NULL,
  `jg_estdo` BIT NOT NULL,
  PRIMARY KEY (`jg_cdgo`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`premio_raspado`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`premio_raspado` (
  `pr_cdgo` INT NOT NULL AUTO_INCREMENT,
  `pr_vlor` INT NOT NULL,
  `pr_prmio_imprso` VARCHAR(45) NOT NULL,
  `pr_estdo` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`pr_cdgo`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`imagen`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`imagen` (
  `im_cdgo` INT NOT NULL AUTO_INCREMENT,
  `im_juego_cdgo` INT NOT NULL,
  `im_dscrpcion` VARCHAR(45) NOT NULL,
  `im_rta_dspstvo` VARCHAR(75) NOT NULL,
  `im_rta_imprsion` VARCHAR(75) NOT NULL,
  `im_estdo` BIT NOT NULL,
  INDEX `fk_imagenes_juego1_idx` (`im_juego_cdgo` ASC) VISIBLE,
  PRIMARY KEY (`im_cdgo`),
  CONSTRAINT `fk_imagenes_juego1`
    FOREIGN KEY (`im_juego_cdgo`)
    REFERENCES `mydb`.`juego` (`jg_cdgo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`tiquete`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`tiquete` (
  `tq_cdgo` BIGINT NOT NULL AUTO_INCREMENT,
  `tq_cdgo_sgrdad` INT NOT NULL,
  `tq_juego_cdgo` INT NOT NULL,
  `tq_1a_imagen_cdgo` INT NOT NULL,
  `tq_1b_imagen_cdgo` INT NOT NULL,
  `tq_1c_imagen_cdgo` INT NOT NULL,
  `tq_2a_imagen_cdgo` INT NOT NULL,
  `tq_2b_imagen_cdgo` INT NOT NULL,
  `tq_2c_imagen_cdgo` INT NOT NULL,
  `tq_premio_raspado_cdgo` INT NOT NULL,
  `tq_gno` BIT NOT NULL,
  `tq_fcha_rspdo` DATE NULL,
  `tq_usuario_cdla` VARCHAR(45) NULL,
  `tq_vendedor_cdla` VARCHAR(45) NULL,
  `tq_prcntje_cmsion_vnddor` FLOAT NULL,
  `tq_usdo` BIT NOT NULL,
  `tq_prcsdo` BIT NOT NULL,
  `tq_rfrdo_vendedor_cdla` VARCHAR(45) NULL,
  `tq_rfrdo_prcntje` FLOAT NULL,
  `tq_fue_vlver_intntar` BIT NULL,
  `tq_estad` BIT NOT NULL,
  PRIMARY KEY (`tq_cdgo`),
  INDEX `fk_programacion_juego1_idx` (`tq_juego_cdgo` ASC) VISIBLE,
  INDEX `fk_programacion_premio_raspado1_idx` (`tq_premio_raspado_cdgo` ASC) VISIBLE,
  INDEX `fk_tiquete_usuario1_idx` (`tq_usuario_cdla` ASC) VISIBLE,
  INDEX `fk_tiquete_imagen1_idx` (`tq_1a_imagen_cdgo` ASC) VISIBLE,
  INDEX `fk_tiquete_imagen2_idx` (`tq_1b_imagen_cdgo` ASC) VISIBLE,
  INDEX `fk_tiquete_imagen3_idx` (`tq_1c_imagen_cdgo` ASC) VISIBLE,
  INDEX `fk_tiquete_imagen4_idx` (`tq_2a_imagen_cdgo` ASC) VISIBLE,
  INDEX `fk_tiquete_imagen5_idx` (`tq_2b_imagen_cdgo` ASC) VISIBLE,
  INDEX `fk_tiquete_imagen6_idx` (`tq_2c_imagen_cdgo` ASC) VISIBLE,
  INDEX `fk_tiquete_vendedor1_idx` (`tq_rfrdo_vendedor_cdla` ASC) VISIBLE,
  INDEX `fk_tiquete_vendedor2_idx` (`tq_vendedor_cdla` ASC) VISIBLE,
  CONSTRAINT `fk_programacion_juego1`
    FOREIGN KEY (`tq_juego_cdgo`)
    REFERENCES `mydb`.`juego` (`jg_cdgo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_programacion_premio_raspado1`
    FOREIGN KEY (`tq_premio_raspado_cdgo`)
    REFERENCES `mydb`.`premio_raspado` (`pr_cdgo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_tiquete_usuario1`
    FOREIGN KEY (`tq_usuario_cdla`)
    REFERENCES `mydb`.`usuario` (`us_cdla`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_tiquete_imagen1`
    FOREIGN KEY (`tq_1a_imagen_cdgo`)
    REFERENCES `mydb`.`imagen` (`im_cdgo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_tiquete_imagen2`
    FOREIGN KEY (`tq_1b_imagen_cdgo`)
    REFERENCES `mydb`.`imagen` (`im_cdgo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_tiquete_imagen3`
    FOREIGN KEY (`tq_1c_imagen_cdgo`)
    REFERENCES `mydb`.`imagen` (`im_cdgo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_tiquete_imagen4`
    FOREIGN KEY (`tq_2a_imagen_cdgo`)
    REFERENCES `mydb`.`imagen` (`im_cdgo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_tiquete_imagen5`
    FOREIGN KEY (`tq_2b_imagen_cdgo`)
    REFERENCES `mydb`.`imagen` (`im_cdgo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_tiquete_imagen6`
    FOREIGN KEY (`tq_2c_imagen_cdgo`)
    REFERENCES `mydb`.`imagen` (`im_cdgo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_tiquete_vendedor1`
    FOREIGN KEY (`tq_rfrdo_vendedor_cdla`)
    REFERENCES `mydb`.`vendedor` (`vd_cdla`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_tiquete_vendedor2`
    FOREIGN KEY (`tq_vendedor_cdla`)
    REFERENCES `mydb`.`vendedor` (`vd_cdla`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`correo_mensajeria`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`correo_mensajeria` (
  `cm_cdgo` INT NOT NULL AUTO_INCREMENT,
  `cm_nmbre_crreo` VARCHAR(75) NOT NULL,
  `cm_prto` INT NOT NULL,
  `cm_clve` VARCHAR(75) NOT NULL,
  `cm_srver_slda` VARCHAR(75) NOT NULL,
  `cm_estd` BIT NOT NULL,
  PRIMARY KEY (`cm_cdgo`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`permiso`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`permiso` (
  `pm_cdgo` INT NOT NULL AUTO_INCREMENT,
  `pm_desc` VARCHAR(45) NOT NULL,
  `pm_estad` BIT NOT NULL,
  PRIMARY KEY (`pm_cdgo`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`perfil_permiso`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`perfil_permiso` (
  `pp_perfil_cdgo` INT NOT NULL,
  `pp_permiso_cdgo` INT NOT NULL,
  PRIMARY KEY (`pp_perfil_cdgo`, `pp_permiso_cdgo`),
  INDEX `fk_perfil_has_permiso_permiso1_idx` (`pp_permiso_cdgo` ASC) VISIBLE,
  INDEX `fk_perfil_has_permiso_perfil1_idx` (`pp_perfil_cdgo` ASC) VISIBLE,
  CONSTRAINT `fk_perfil_has_permiso_perfil1`
    FOREIGN KEY (`pp_perfil_cdgo`)
    REFERENCES `mydb`.`perfil` (`pf_cdgo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_perfil_has_permiso_permiso1`
    FOREIGN KEY (`pp_permiso_cdgo`)
    REFERENCES `mydb`.`permiso` (`pm_cdgo`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`debito`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`debito` (
  `db_cdgo` INT NOT NULL,
  `db_fcha` DATE NOT NULL,
  `db_vlor` INT NOT NULL,
  `db_dscrpcion` VARCHAR(500) NOT NULL,
  `db_estdo` BIT NOT NULL,
  `db_usuario_cdla` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`db_cdgo`),
  INDEX `fk_debito_usuario1_idx` (`db_usuario_cdla` ASC) VISIBLE,
  CONSTRAINT `fk_debito_usuario1`
    FOREIGN KEY (`db_usuario_cdla`)
    REFERENCES `mydb`.`usuario` (`us_cdla`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`usuario_abono`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`usuario_abono` (
  `ua_cdgo` INT NOT NULL AUTO_INCREMENT,
  `ua_fcha` DATE NOT NULL,
  `ua_vendedor_cdla` VARCHAR(45) NOT NULL,
  `ua_usuario_quien_rgstra_cdla` VARCHAR(45) NOT NULL,
  `ua_fcha_rgstro` TIMESTAMP NOT NULL,
  `ua_dscrpcion` VARCHAR(1000) NULL,
  `ua_vlor` INT NOT NULL,
  `ua_estdo` BIT NOT NULL,
  PRIMARY KEY (`ua_cdgo`),
  INDEX `fk_usuario_abono_usuario1_idx` (`ua_usuario_quien_rgstra_cdla` ASC) VISIBLE,
  INDEX `fk_usuario_abono_vendedor1_idx` (`ua_vendedor_cdla` ASC) VISIBLE,
  CONSTRAINT `fk_usuario_abono_usuario1`
    FOREIGN KEY (`ua_usuario_quien_rgstra_cdla`)
    REFERENCES `mydb`.`usuario` (`us_cdla`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_usuario_abono_vendedor1`
    FOREIGN KEY (`ua_vendedor_cdla`)
    REFERENCES `mydb`.`vendedor` (`vd_cdla`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`usuario_al_dia`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`usuario_al_dia` (
  `udia_cdgo` BIGINT NOT NULL AUTO_INCREMENT,
  `udia_fcha` DATE NOT NULL,
  `udia_vendedor_cdla` VARCHAR(45) NOT NULL,
  `udia_usuario_quien_rgstra_cdla` VARCHAR(45) NOT NULL,
  `udia_fcha_rgstro` TIMESTAMP NOT NULL,
  `udia_dscrpcion` VARCHAR(1000) NOT NULL,
  `udia_estdo` BIT NOT NULL,
  PRIMARY KEY (`udia_cdgo`),
  INDEX `fk_usuario_al_dia_usuario1_idx` (`udia_usuario_quien_rgstra_cdla` ASC) VISIBLE,
  INDEX `fk_usuario_al_dia_vendedor1_idx` (`udia_vendedor_cdla` ASC) VISIBLE,
  CONSTRAINT `fk_usuario_al_dia_usuario1`
    FOREIGN KEY (`udia_usuario_quien_rgstra_cdla`)
    REFERENCES `mydb`.`usuario` (`us_cdla`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_usuario_al_dia_vendedor1`
    FOREIGN KEY (`udia_vendedor_cdla`)
    REFERENCES `mydb`.`vendedor` (`vd_cdla`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`usuario_descuento`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`usuario_descuento` (
  `udes_cdgo` BIGINT NOT NULL AUTO_INCREMENT,
  `udes_fcha` DATE NOT NULL,
  `udes_vendedor_cdla` VARCHAR(45) NOT NULL,
  `udes_usuario_quien_rgstra_cdla` VARCHAR(45) NOT NULL,
  `udes_fcha_rgstro` TIMESTAMP NOT NULL,
  `udes_dscrpcion` VARCHAR(1000) NOT NULL,
  `udes_vlor` INT NOT NULL,
  `udes_estad` BIT NOT NULL,
  PRIMARY KEY (`udes_cdgo`),
  INDEX `fk_usuario_descuento_usuario1_idx` (`udes_usuario_quien_rgstra_cdla` ASC) VISIBLE,
  INDEX `fk_usuario_descuento_vendedor1_idx` (`udes_vendedor_cdla` ASC) VISIBLE,
  CONSTRAINT `fk_usuario_descuento_usuario1`
    FOREIGN KEY (`udes_usuario_quien_rgstra_cdla`)
    REFERENCES `mydb`.`usuario` (`us_cdla`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_usuario_descuento_vendedor1`
    FOREIGN KEY (`udes_vendedor_cdla`)
    REFERENCES `mydb`.`vendedor` (`vd_cdla`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`usuario_deuda`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`usuario_deuda` (
  `udeu_cdgo` BIGINT NOT NULL AUTO_INCREMENT,
  `udeu_fcha` DATE NOT NULL,
  `udeu_usuario_quien_rgstra_cdla` VARCHAR(45) NOT NULL,
  `udeu_vendedor_cdla` VARCHAR(45) NOT NULL,
  `udeu_fcha_rgstro` TIMESTAMP NOT NULL,
  `udeu_dscrpcion` VARCHAR(1000) NOT NULL,
  `udeu_vlor` INT NOT NULL,
  `udeu_estad` BIT NOT NULL,
  PRIMARY KEY (`udeu_cdgo`),
  INDEX `fk_usuario_deuda_usuario1_idx` (`udeu_usuario_quien_rgstra_cdla` ASC) VISIBLE,
  INDEX `fk_usuario_deuda_vendedor1_idx` (`udeu_vendedor_cdla` ASC) VISIBLE,
  CONSTRAINT `fk_usuario_deuda_usuario1`
    FOREIGN KEY (`udeu_usuario_quien_rgstra_cdla`)
    REFERENCES `mydb`.`usuario` (`us_cdla`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_usuario_deuda_vendedor1`
    FOREIGN KEY (`udeu_vendedor_cdla`)
    REFERENCES `mydb`.`vendedor` (`vd_cdla`)
    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;
