text: -- MySQL Script generated by MySQL Workbench
  -- Mon Dec 24 10:30:04 2018
  -- 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 ;
  -- -----------------------------------------------------
  -- Schema sispmscore
  -- -----------------------------------------------------
  
  -- -----------------------------------------------------
  -- Schema sispmscore
  -- -----------------------------------------------------
  CREATE SCHEMA IF NOT EXISTS `sispmscore` DEFAULT CHARACTER SET utf8 ;
  USE `mydb` ;
  
  -- -----------------------------------------------------
  -- Table `mydb`.`cargo`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `mydb`.`cargo` (
    `idcargo` INT NOT NULL AUTO_INCREMENT,
    `nome` VARCHAR(45) NULL,
    `descricao` VARCHAR(45) NULL,
    PRIMARY KEY (`idcargo`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `mydb`.`ocorrencia`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `mydb`.`ocorrencia` (
    `idocorrencia` INT NOT NULL AUTO_INCREMENT,
    `numero` INT NULL,
    `descricao` VARCHAR(255) NULL,
    PRIMARY KEY (`idocorrencia`))
  ENGINE = InnoDB;
  
  
  -- -----------------------------------------------------
  -- Table `mydb`.`prestadora_servico`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `mydb`.`prestadora_servico` (
    `idprestadora_servico` INT NOT NULL AUTO_INCREMENT,
    `razao_social` VARCHAR(45) NULL,
    `cnpj` VARCHAR(100) NULL,
    `email` VARCHAR(45) NULL,
    `telefone` VARCHAR(45) NULL,
    `cep` VARCHAR(45) NULL,
    `endereco` VARCHAR(45) NULL,
    `bairro` VARCHAR(45) NULL,
    `cidade` VARCHAR(45) NULL,
    `pais` VARCHAR(45) NULL,
    `descricao` VARCHAR(45) NULL,
    PRIMARY KEY (`idprestadora_servico`))
  ENGINE = InnoDB;
  
  USE `sispmscore` ;
  
  -- -----------------------------------------------------
  -- Table `sispmscore`.`tiposetor`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `sispmscore`.`tiposetor` (
    `idtipo_setor` INT(11) NOT NULL AUTO_INCREMENT,
    `nome` VARCHAR(45) NULL DEFAULT NULL,
    `descricao` VARCHAR(255) NULL DEFAULT NULL,
    PRIMARY KEY (`idtipo_setor`))
  ENGINE = InnoDB
  AUTO_INCREMENT = 12
  DEFAULT CHARACTER SET = utf8;
  
  
  -- -----------------------------------------------------
  -- Table `sispmscore`.`setor`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `sispmscore`.`setor` (
    `idsetor` INT(11) NOT NULL AUTO_INCREMENT,
    `codigo` INT(11) NULL DEFAULT NULL,
    `nome` VARCHAR(45) NULL DEFAULT NULL,
    `telefone1` VARCHAR(100) NULL DEFAULT NULL,
    `telefone2` VARCHAR(100) NULL DEFAULT NULL,
    `cep` VARCHAR(100) NULL DEFAULT NULL,
    `bairro` VARCHAR(100) NULL DEFAULT NULL,
    `logradouro` VARCHAR(100) NULL DEFAULT NULL,
    `numero` INT(11) NULL DEFAULT NULL,
    `latitude` VARCHAR(255) NULL DEFAULT NULL,
    `longitude` VARCHAR(255) NULL DEFAULT NULL,
    `gestor` VARCHAR(255) NULL DEFAULT NULL,
    `tipo_setor_idtipo_setor` INT(11) NOT NULL,
    PRIMARY KEY (`idsetor`),
    INDEX `fk_setor_tipo_setor_idx` (`tipo_setor_idtipo_setor` ASC),
    CONSTRAINT `fk_setor_tipo_setor`
      FOREIGN KEY (`tipo_setor_idtipo_setor`)
      REFERENCES `sispmscore`.`tiposetor` (`idtipo_setor`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB
  AUTO_INCREMENT = 3
  DEFAULT CHARACTER SET = utf8;
  
  
  -- -----------------------------------------------------
  -- Table `sispmscore`.`usuario`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `sispmscore`.`usuario` (
    `idusuario` INT(11) NOT NULL AUTO_INCREMENT,
    `nome` VARCHAR(100) NULL DEFAULT NULL,
    `email` VARCHAR(100) NULL DEFAULT NULL,
    `senha` VARCHAR(100) NULL DEFAULT NULL,
    `data` DATE NULL DEFAULT NULL,
    `setor_idsetor` INT(11) NOT NULL,
    PRIMARY KEY (`idusuario`),
    INDEX `fk_usuario_setor1_idx` (`setor_idsetor` ASC),
    CONSTRAINT `fk_usuario_setor1`
      FOREIGN KEY (`setor_idsetor`)
      REFERENCES `sispmscore`.`setor` (`idsetor`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB
  AUTO_INCREMENT = 2
  DEFAULT CHARACTER SET = utf8;
  
  
  -- -----------------------------------------------------
  -- Table `sispmscore`.`anotacoes_setor`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `sispmscore`.`anotacoes_setor` (
    `idanotacoes` INT(11) NOT NULL AUTO_INCREMENT,
    `nota` VARCHAR(255) NULL DEFAULT NULL,
    `anotacoescol` VARCHAR(45) NULL DEFAULT NULL,
    `setor_idsetor` INT(11) NOT NULL,
    `usuario_idusuario` INT(11) NOT NULL,
    PRIMARY KEY (`idanotacoes`),
    INDEX `fk_anotacoes_setor1_idx` (`setor_idsetor` ASC),
    INDEX `fk_anotacoes_usuario1_idx` (`usuario_idusuario` ASC),
    CONSTRAINT `fk_anotacoes_setor1`
      FOREIGN KEY (`setor_idsetor`)
      REFERENCES `sispmscore`.`setor` (`idsetor`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_anotacoes_usuario1`
      FOREIGN KEY (`usuario_idusuario`)
      REFERENCES `sispmscore`.`usuario` (`idusuario`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB
  DEFAULT CHARACTER SET = utf8;
  
  
  -- -----------------------------------------------------
  -- Table `sispmscore`.`colaborador`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `sispmscore`.`colaborador` (
    `idcolaborador` INT(11) NOT NULL AUTO_INCREMENT,
    `nome` VARCHAR(45) NULL DEFAULT NULL,
    `cpf` VARCHAR(255) NULL DEFAULT NULL,
    `data_admissao` VARCHAR(255) NULL DEFAULT NULL,
    `telefone` VARCHAR(45) NULL DEFAULT NULL,
    `setor_idsetor` INT(11) NOT NULL,
    `cargo_idcargo` INT NOT NULL,
    `ocorrencia_idocorrencia` INT NOT NULL,
    `prestadora_servico_idprestadora_servico` INT NOT NULL,
    PRIMARY KEY (`idcolaborador`),
    INDEX `fk_colaborador_setor1_idx` (`setor_idsetor` ASC),
    INDEX `fk_colaborador_cargo1_idx` (`cargo_idcargo` ASC),
    INDEX `fk_colaborador_ocorrencia1_idx` (`ocorrencia_idocorrencia` ASC),
    INDEX `fk_colaborador_prestadora_servico1_idx` (`prestadora_servico_idprestadora_servico` ASC),
    CONSTRAINT `fk_colaborador_setor1`
      FOREIGN KEY (`setor_idsetor`)
      REFERENCES `sispmscore`.`setor` (`idsetor`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_colaborador_cargo1`
      FOREIGN KEY (`cargo_idcargo`)
      REFERENCES `mydb`.`cargo` (`idcargo`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_colaborador_ocorrencia1`
      FOREIGN KEY (`ocorrencia_idocorrencia`)
      REFERENCES `mydb`.`ocorrencia` (`idocorrencia`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_colaborador_prestadora_servico1`
      FOREIGN KEY (`prestadora_servico_idprestadora_servico`)
      REFERENCES `mydb`.`prestadora_servico` (`idprestadora_servico`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB
  DEFAULT CHARACTER SET = utf8;
  
  
  -- -----------------------------------------------------
  -- Table `sispmscore`.`historico`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `sispmscore`.`historico` (
    `idhistorico` INT(11) NOT NULL AUTO_INCREMENT,
    `data` DATE NOT NULL,
    `observacao` VARCHAR(255) NULL DEFAULT NULL,
    `historicocol` VARCHAR(45) NULL DEFAULT NULL,
    `colaborador_idcolaborador` INT(11) NOT NULL,
    `setor_idsetor` INT(11) NOT NULL,
    `usuario_idusuario` INT(11) NOT NULL,
    PRIMARY KEY (`idhistorico`),
    INDEX `fk_historico_colaborador1_idx` (`colaborador_idcolaborador` ASC),
    INDEX `fk_historico_setor1_idx` (`setor_idsetor` ASC),
    INDEX `fk_historico_usuario1_idx` (`usuario_idusuario` ASC),
    CONSTRAINT `fk_historico_colaborador1`
      FOREIGN KEY (`colaborador_idcolaborador`)
      REFERENCES `sispmscore`.`colaborador` (`idcolaborador`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_historico_setor1`
      FOREIGN KEY (`setor_idsetor`)
      REFERENCES `sispmscore`.`setor` (`idsetor`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `fk_historico_usuario1`
      FOREIGN KEY (`usuario_idusuario`)
      REFERENCES `sispmscore`.`usuario` (`idusuario`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB
  DEFAULT CHARACTER SET = utf8;
  
  
  -- -----------------------------------------------------
  -- Table `sispmscore`.`professor`
  -- -----------------------------------------------------
  CREATE TABLE IF NOT EXISTS `sispmscore`.`professor` (
    `idprofessor` INT(11) NOT NULL,
    `codigo` INT(11) NULL DEFAULT NULL,
    `segmento` VARCHAR(45) NULL DEFAULT NULL,
    `professorcol` VARCHAR(45) NULL DEFAULT NULL,
    `ano_escolarizacao` VARCHAR(45) NULL DEFAULT NULL,
    `turno` VARCHAR(45) NULL DEFAULT NULL,
    `turma` VARCHAR(45) NULL DEFAULT NULL,
    `matricula` VARCHAR(45) NULL DEFAULT NULL,
    `nome` VARCHAR(255) NULL DEFAULT NULL,
    `setor_idsetor` INT(11) NOT NULL,
    PRIMARY KEY (`idprofessor`),
    INDEX `fk_professor_setor1_idx` (`setor_idsetor` ASC),
    CONSTRAINT `fk_professor_setor1`
      FOREIGN KEY (`setor_idsetor`)
      REFERENCES `sispmscore`.`setor` (`idsetor`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB
  DEFAULT CHARACTER SET = utf8;
  
  
  SET SQL_MODE=@OLD_SQL_MODE;
  SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
  SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  