-- 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 indikae
-- -----------------------------------------------------

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

-- -----------------------------------------------------
-- Table `indikae`.`TIPO_PARTICIPANTE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`TIPO_PARTICIPANTE` (
  `ID` INT NOT NULL,
  `TIPO_PARTICIPANTE` VARCHAR(20) NOT NULL,
  PRIMARY KEY (`ID`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`UF`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`UF` (
  `UF` VARCHAR(2) NOT NULL,
  `DESCRICAO` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`UF`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`CIDADE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`CIDADE` (
  `CIDADE` VARCHAR(45) NOT NULL,
  `UF` VARCHAR(2) NOT NULL,
  PRIMARY KEY (`CIDADE`),
  INDEX `fk_Cidade_UF1_idx` (`UF` ASC),
  CONSTRAINT `fk_CIDADE_UF1`
    FOREIGN KEY (`UF`)
    REFERENCES `indikae`.`UF` (`UF`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`BAIRRO`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`BAIRRO` (
  `BAIRRO` VARCHAR(45) NOT NULL,
  `UF` VARCHAR(2) NOT NULL,
  `CIDADE` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`BAIRRO`),
  INDEX `fk_Bairro_UF1_idx` (`UF` ASC),
  INDEX `fk_Bairro_Cidade1_idx` (`CIDADE` ASC),
  CONSTRAINT `fk_BAIRRO_UF1`
    FOREIGN KEY (`UF`)
    REFERENCES `indikae`.`UF` (`UF`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_BAIRRO_CIDADE1`
    FOREIGN KEY (`CIDADE`)
    REFERENCES `indikae`.`CIDADE` (`CIDADE`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`REGIAO`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`REGIAO` (
  `ID` INT NOT NULL,
  `UF` VARCHAR(2) NOT NULL,
  `CIDADE` VARCHAR(45) NULL,
  `BAIRRO` VARCHAR(45) NULL,
  PRIMARY KEY (`ID`),
  INDEX `fk_Regiao_UF1_idx` (`UF` ASC),
  INDEX `fk_Regiao_Cidade1_idx` (`CIDADE` ASC),
  INDEX `fk_Regiao_Bairro1_idx` (`BAIRRO` ASC),
  CONSTRAINT `fk_REGIAO_UF1`
    FOREIGN KEY (`UF`)
    REFERENCES `indikae`.`UF` (`UF`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_REGIAO_CIDADE1`
    FOREIGN KEY (`CIDADE`)
    REFERENCES `indikae`.`CIDADE` (`CIDADE`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_REGIAO_BAIRRO1`
    FOREIGN KEY (`BAIRRO`)
    REFERENCES `indikae`.`BAIRRO` (`BAIRRO`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`PARTICIPANTE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`PARTICIPANTE` (
  `ID` INT NOT NULL,
  `ID_TIPO_PARTICIPANTE` INT NOT NULL,
  `NOME` VARCHAR(45) NOT NULL,
  `EMAIL` VARCHAR(45) NOT NULL,
  `TELEFONE_CELULAR` INT NOT NULL,
  `TELEFONE_RESIDENCIAL` INT NULL,
  `TIPO_PESSOA` CHAR(1) NOT NULL,
  `CPF` VARCHAR(11) NULL,
  `CNPJ` VARCHAR(14) NULL,
  `ID_REGIAO` INT NOT NULL,
  `ENDERECO` VARCHAR(100) NOT NULL,
  `NUMERO` INT NOT NULL,
  `COMPLEMENTO` VARCHAR(45) NULL,
  `PONTO_REFERENCIA` VARCHAR(100) NULL,
  `HOMEPAGE` VARCHAR(45) NULL,
  PRIMARY KEY (`ID`),
  UNIQUE INDEX `idParticipante_UNIQUE` (`ID` ASC),
  INDEX `fk_Participante_TipoParticipante1_idx` (`ID_TIPO_PARTICIPANTE` ASC),
  INDEX `fk_Participante_Regiao1_idx` (`ID_REGIAO` ASC),
  CONSTRAINT `fk_PARTICIPANTE_TIPO_PARTICIPANTE1`
    FOREIGN KEY (`ID_TIPO_PARTICIPANTE`)
    REFERENCES `indikae`.`TIPO_PARTICIPANTE` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_PARTICIPANTE_REGIAO1`
    FOREIGN KEY (`ID_REGIAO`)
    REFERENCES `indikae`.`REGIAO` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`TIPO_SERVICO`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`TIPO_SERVICO` (
  `ID` INT NOT NULL,
  `CATEGORIA_SERVICO` VARCHAR(45) NULL,
  `TIPO_SERVICO` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`ID`),
  UNIQUE INDEX `idTipoServico_UNIQUE` (`ID` ASC))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`DIA_SEMANA`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`DIA_SEMANA` (
  `ID` INT NOT NULL,
  `DIA_SEMANA` VARCHAR(10) NOT NULL,
  PRIMARY KEY (`ID`),
  UNIQUE INDEX `DiaSemana_UNIQUE` (`DIA_SEMANA` ASC))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`DISPONIBILIDADE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`DISPONIBILIDADE` (
  `ID` INT NOT NULL,
  `ID_DIA_SEMANA` INT NOT NULL,
  `HORA_INI` TIME(2) NULL,
  `HORA_FIM` TIME(2) NULL,
  PRIMARY KEY (`ID`),
  INDEX `fk_Disponibilidade_DiaSemana1_idx` (`ID_DIA_SEMANA` ASC),
  CONSTRAINT `fk_DISP_DIA_SEMANA1`
    FOREIGN KEY (`ID_DIA_SEMANA`)
    REFERENCES `indikae`.`DIA_SEMANA` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`SERVICO`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`SERVICO` (
  `ID` INT NOT NULL,
  `ID_TIPO_SERVICO` INT NOT NULL,
  `ID_DISPONIBILIDADE` INT NOT NULL,
  `DISPONIVEL_MOMENTO` CHAR(1) NOT NULL,
  `DATA_RETORNO` DATE NULL,
  `ATENDE_ENDERECO_FORNECEDOR` CHAR(1) NULL,
  `ATENDE_CLIENTE_DELIVERY` CHAR(1) NULL,
  `LIGUE_GRATIS` CHAR(1) NULL,
  `ESTACIONAMENTO_PROPRIO` CHAR(1) NULL,
  `WIFI_INTERNET` CHAR(1) NULL,
  `SEGURANCA` CHAR(1) NULL,
  `AR_CONDICIONADO` CHAR(1) NULL,
  `ACESSO_PORTADORES` CHAR(1) NULL,
  `TRANSPORTE_LEVA_TRAZ` CHAR(1) NULL,
  `ESPACO_KIDS` CHAR(1) NULL,
  PRIMARY KEY (`ID`),
  INDEX `fk_Servico_TipoServico1_idx` (`ID_TIPO_SERVICO` ASC),
  INDEX `fk_Servico_Disponibilidade1_idx` (`ID_DISPONIBILIDADE` ASC),
  CONSTRAINT `fk_SERVICO_TIPO_SERVICO1`
    FOREIGN KEY (`ID_TIPO_SERVICO`)
    REFERENCES `indikae`.`TIPO_SERVICO` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_SERVICO_DISPONIBILIDADE1`
    FOREIGN KEY (`ID_DISPONIBILIDADE`)
    REFERENCES `indikae`.`DISPONIBILIDADE` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`REL_SERVICO_REGIAO`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`REL_SERVICO_REGIAO` (
  `ID` INT NOT NULL,
  `ID_SERVICO` INT NOT NULL,
  `ID_REGIAO` INT NOT NULL,
  PRIMARY KEY (`ID`, `ID_REGIAO`),
  INDEX `fk_RelServReg_Regiao1_idx` (`ID_REGIAO` ASC),
  INDEX `fk_RelServReg_Servico1_idx` (`ID_SERVICO` ASC),
  CONSTRAINT `fk_REL_SERV_REG_REGIAO1`
    FOREIGN KEY (`ID_REGIAO`)
    REFERENCES `indikae`.`REGIAO` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_REL_SERV_REG_SERVICO1`
    FOREIGN KEY (`ID_SERVICO`)
    REFERENCES `indikae`.`SERVICO` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`POSICAO_ANUNCIO`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`POSICAO_ANUNCIO` (
  `ID` INT NOT NULL,
  `DESCRICAO` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`ID`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`PLANO`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`PLANO` (
  `ID` INT NOT NULL,
  `PLANO` VARCHAR(45) NOT NULL,
  `DATA_INI` DATE NOT NULL,
  `DATA_FIM` DATE NULL,
  `VALOR` DECIMAL NOT NULL,
  `BUSCA_SERVICO` CHAR(1) NOT NULL,
  `NRO_SERVICOS` INT NOT NULL,
  `NRO_REGIOES` INT NULL,
  `VISITA_AUTOM_FORNECEDORES` CHAR(1) NOT NULL,
  `CHAT` CHAR(1) NOT NULL,
  `NRO_CHAT_DIARIO` INT NULL,
  `NRO_VISUAL_FORN_DIARIO` INT NULL,
  `NRO_LICITACAO_SIMULT` INT NULL,
  `AGENDA_DISPONIBILIDADE` CHAR(1) NULL,
  `TERRITORIO_NACIONAL` CHAR(1) NULL,
  `NRO_CLIENTES_LISTA` INT NULL,
  `NRO_FORNECEDORES_LISTA` INT NULL,
  `ID_POSICAO_ANUNCIO` INT NOT NULL,
  PRIMARY KEY (`ID`),
  INDEX `fk_Plano_PosicaoAnuncio1_idx` (`ID_POSICAO_ANUNCIO` ASC),
  CONSTRAINT `fk_PLANO_POSICAO_ANUNCIO1`
    FOREIGN KEY (`ID_POSICAO_ANUNCIO`)
    REFERENCES `indikae`.`POSICAO_ANUNCIO` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`PLANO_FORNECEDOR`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`PLANO_FORNECEDOR` (
  `ID` INT NOT NULL,
  `ID_PLANO` INT NOT NULL,
  `ID_PARTICIPANTE` INT NOT NULL,
  `DATA_INI` DATE NOT NULL,
  `DATA_FIM` DATE NOT NULL,
  `DATA_CANCELAMENTO` DATE NULL,
  `MOTIVO` VARCHAR(100) NULL,
  PRIMARY KEY (`ID`),
  INDEX `fk_PlanoFornecedor_Plano1_idx` (`ID_PLANO` ASC),
  INDEX `fk_PlanoFornecedor_Participante1_idx` (`ID_PARTICIPANTE` ASC),
  UNIQUE INDEX `DATA_FIM_UNIQUE` (`DATA_FIM` ASC),
  UNIQUE INDEX `DATA_INI_UNIQUE` (`DATA_INI` ASC),
  UNIQUE INDEX `ID_PARTICIPANTE_UNIQUE` (`ID_PARTICIPANTE` ASC),
  UNIQUE INDEX `ID_PLANO_UNIQUE` (`ID_PLANO` ASC),
  UNIQUE INDEX `ID_UNIQUE` (`ID` ASC),
  CONSTRAINT `fk_PLANO_FORNECEDOR_PLANO1`
    FOREIGN KEY (`ID_PLANO`)
    REFERENCES `indikae`.`PLANO` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_PLANO_FORNECEDOR_PARTICIPANTE1`
    FOREIGN KEY (`ID_PARTICIPANTE`)
    REFERENCES `indikae`.`PARTICIPANTE` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`SENHA`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`SENHA` (
  `ID` INT NOT NULL,
  `SENHA` VARCHAR(45) NOT NULL,
  `ID_PARTICIPANTE` INT NOT NULL,
  `DATA_INI` DATE NOT NULL,
  `DATA_FIM` DATE NOT NULL,
  PRIMARY KEY (`ID`),
  INDEX `fk_Senha_Participante1_idx` (`ID_PARTICIPANTE` ASC),
  CONSTRAINT `fk_Senha_Participante1`
    FOREIGN KEY (`ID_PARTICIPANTE`)
    REFERENCES `indikae`.`PARTICIPANTE` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`SERVICO_VIEWS`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`SERVICO_VIEWS` (
  `ID` INT NOT NULL,
  `DATA_VIEW` DATE NULL,
  `ID_SERVICO` INT NOT NULL,
  `ID_PARTICIPANTE` INT NOT NULL,
  PRIMARY KEY (`ID`),
  INDEX `fk_ServicoViews_Servico1_idx` (`ID_SERVICO` ASC),
  INDEX `fk_ServicoViews_Participante1_idx` (`ID_PARTICIPANTE` ASC),
  CONSTRAINT `fk_SERVICO_VIEWS_SERVICO1`
    FOREIGN KEY (`ID_SERVICO`)
    REFERENCES `indikae`.`SERVICO` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_SERVICO_VIEWS_PARTICIPANTE1`
    FOREIGN KEY (`ID_PARTICIPANTE`)
    REFERENCES `indikae`.`PARTICIPANTE` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`AVALIACAO`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`AVALIACAO` (
  `ID` INT NOT NULL,
  `AVALIACAO` INT NOT NULL,
  `OBSERVACAO` VARCHAR(200) NULL,
  `ID_SERVICO` INT NOT NULL,
  `ID_PARTICIPANTE` INT NOT NULL,
  PRIMARY KEY (`ID`),
  INDEX `fk_Avaliacao_Servico1_idx` (`ID_SERVICO` ASC),
  INDEX `fk_AVALIACAO_PARTICIPANTE2_idx` (`ID_PARTICIPANTE` ASC),
  CONSTRAINT `fk_AVALIACAO_SERVICO1`
    FOREIGN KEY (`ID_SERVICO`)
    REFERENCES `indikae`.`SERVICO` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_AVALIACAO_PARTICIPANTE2`
    FOREIGN KEY (`ID_PARTICIPANTE`)
    REFERENCES `indikae`.`PARTICIPANTE` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`INDICACAO`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`INDICACAO` (
  `ID` INT NOT NULL,
  `ID_QUEM_INDICOU` INT NOT NULL,
  `ID_INDICADO` INT NOT NULL,
  `DATA_INDICACAO` DATE NOT NULL,
  `OBSERVACAO` VARCHAR(100) NULL,
  `DATA_ACEITACAO` DATE NULL,
  `ID_TIPO_SERVICO` INT NOT NULL,
  PRIMARY KEY (`ID`),
  INDEX `fk_Indicacao_Participante1_idx` (`ID_QUEM_INDICOU` ASC),
  INDEX `fk_Indicacao_Participante2_idx` (`ID_INDICADO` ASC),
  INDEX `fk_INDICACAO_TIPO_SERVICO1_idx` (`ID_TIPO_SERVICO` ASC),
  CONSTRAINT `fk_INDICACAO_PARTICIPANTE1`
    FOREIGN KEY (`ID_QUEM_INDICOU`)
    REFERENCES `indikae`.`PARTICIPANTE` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_INDICACAO_PARTICIPANTE2`
    FOREIGN KEY (`ID_INDICADO`)
    REFERENCES `indikae`.`PARTICIPANTE` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_INDICACAO_TIPO_SERVICO1`
    FOREIGN KEY (`ID_TIPO_SERVICO`)
    REFERENCES `indikae`.`TIPO_SERVICO` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`SERVICO_CLICKS`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`SERVICO_CLICKS` (
  `ID` INT NOT NULL,
  `DATA_CLICK` DATE NOT NULL,
  `ID_SERVICO` INT NOT NULL,
  `ID_PARTICIPANTE` INT NOT NULL,
  PRIMARY KEY (`ID`),
  INDEX `fk_ServicoClicks_Servico1_idx` (`ID_SERVICO` ASC),
  INDEX `fk_ServicoClicks_Participante1_idx` (`ID_PARTICIPANTE` ASC),
  CONSTRAINT `fk_SERVICO_CLICKS_SERVICO1`
    FOREIGN KEY (`ID_SERVICO`)
    REFERENCES `indikae`.`SERVICO` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_SERVICO_CLICKS_PARTICIPANTE1`
    FOREIGN KEY (`ID_PARTICIPANTE`)
    REFERENCES `indikae`.`PARTICIPANTE` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`TIPO_PONTUACAO`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`TIPO_PONTUACAO` (
  `ID` INT NOT NULL,
  `TIPO_PONTUACAO` VARCHAR(45) NOT NULL,
  `VALOR` VARCHAR(45) NULL,
  PRIMARY KEY (`ID`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`PONTUACAO`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`PONTUACAO` (
  `ID` INT NOT NULL,
  `ID_PARTICIPANTE` INT NOT NULL,
  `ID_TIPO_PONTUACAO` INT NOT NULL,
  `DATA` DATETIME(2) NOT NULL,
  PRIMARY KEY (`ID`),
  INDEX `fk_Pontuacao_Participante1_idx` (`ID_PARTICIPANTE` ASC),
  INDEX `fk_Pontuacao_TipoPontuacao1_idx` (`ID_TIPO_PONTUACAO` ASC),
  CONSTRAINT `fk_PONTUACAO_PARTICIPANTE1`
    FOREIGN KEY (`ID_PARTICIPANTE`)
    REFERENCES `indikae`.`PARTICIPANTE` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_PONTUACAO_TIPO_PONTUACAO1`
    FOREIGN KEY (`ID_TIPO_PONTUACAO`)
    REFERENCES `indikae`.`TIPO_PONTUACAO` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`PAGAMENTO`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`PAGAMENTO` (
  `ID` INT NOT NULL,
  `PLANO_FORNECEDOR_ID` INT NOT NULL,
  `VALOR_A_PAGAR` DECIMAL(2) NULL,
  `DATA_VENCIMENTO` DATE NULL,
  `VALOR_PAGO` DECIMAL(2) NULL,
  `DATA_PAGAMENTO` DATE NULL,
  `VALOR_DESCONTO` DECIMAL(2) NULL,
  `MOTIVO_DESCONTO` VARCHAR(255) NULL,
  `VALOR_JUROS` DECIMAL(2) NULL,
  `VALOR_MULTA` DECIMAL(2) NULL,
  `DATA_CANCELAMENTO` DATE NULL,
  `MOTIVO_CANCELAMENTO` VARCHAR(255) NULL,
  PRIMARY KEY (`ID`),
  INDEX `fk_PAGAMENTO_PLANO_FORNECEDOR1_idx` (`PLANO_FORNECEDOR_ID` ASC),
  CONSTRAINT `fk_PAGAMENTO_PLANO_FORNECEDOR1`
    FOREIGN KEY (`PLANO_FORNECEDOR_ID`)
    REFERENCES `indikae`.`PLANO_FORNECEDOR` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`TIPO_CUPOM`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`TIPO_CUPOM` (
  `ID` INT NOT NULL,
  `TIPO_CUPOM` VARCHAR(45) NULL,
  PRIMARY KEY (`ID`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `indikae`.`CUPOM`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `indikae`.`CUPOM` (
  `ID` INT NOT NULL,
  `DATA` DATE NULL,
  `DATA_VALIDADE` DATE NULL,
  `DATA_RETIRADA` DATE NULL,
  `VALOR` DECIMAL(2) NULL,
  `ID_PARTICIPANTE` INT NOT NULL,
  `ID_TIPO_CUPOM` INT NOT NULL,
  PRIMARY KEY (`ID`),
  INDEX `fk_CUPOM_PARTICIPANTE1_idx` (`ID_PARTICIPANTE` ASC),
  INDEX `fk_CUPOM_TIPO_CUPOM1_idx` (`ID_TIPO_CUPOM` ASC),
  CONSTRAINT `fk_CUPOM_PARTICIPANTE1`
    FOREIGN KEY (`ID_PARTICIPANTE`)
    REFERENCES `indikae`.`PARTICIPANTE` (`ID`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_CUPOM_TIPO_CUPOM1`
    FOREIGN KEY (`ID_TIPO_CUPOM`)
    REFERENCES `indikae`.`TIPO_CUPOM` (`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;
