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';

CREATE SCHEMA IF NOT EXISTS `escola` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `escola` ;

-- -----------------------------------------------------
-- Table `escola`.`docentes`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `escola`.`docentes` (
  `do_bi` INT NOT NULL ,
  `do_nome` VARCHAR(45) NOT NULL ,
  `do_password` VARCHAR(45) NULL ,
  PRIMARY KEY (`do_bi`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `escola`.`turmas`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `escola`.`turmas` (
  `tu_id` INT NOT NULL AUTO_INCREMENT ,
  `tu_nome` VARCHAR(20) NOT NULL ,
  PRIMARY KEY (`tu_id`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `escola`.`administradores`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `escola`.`administradores` (
  `adm_login` VARCHAR(45) NOT NULL ,
  `adm_password` VARCHAR(45) NULL ,
  PRIMARY KEY (`adm_login`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `escola`.`disciplinas`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `escola`.`disciplinas` (
  `di_id` INT NOT NULL AUTO_INCREMENT ,
  `di_nome` VARCHAR(45) NOT NULL ,
  PRIMARY KEY (`di_id`) ,
  UNIQUE INDEX `di_nome_UNIQUE` (`di_nome` ASC) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `escola`.`sumarios`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `escola`.`sumarios` (
  `sum_id` INT NOT NULL AUTO_INCREMENT ,
  `sum_data` DATETIME NOT NULL ,
  `sum_numsegmentos` INT NOT NULL ,
  `sum_conteudo` VARCHAR(45) NULL ,
  `docentes_do_bi` INT NOT NULL ,
  `turmas_tu_id` INT NOT NULL ,
  `disciplinas_di_id` INT NOT NULL ,
  PRIMARY KEY (`sum_id`) ,
  INDEX `fk_sumarios_docentes` (`docentes_do_bi` ASC) ,
  INDEX `fk_sumarios_turmas1` (`turmas_tu_id` ASC) ,
  INDEX `fk_sumarios_disciplinas1` (`disciplinas_di_id` ASC) ,
  CONSTRAINT `fk_sumarios_docentes`
    FOREIGN KEY (`docentes_do_bi` )
    REFERENCES `escola`.`docentes` (`do_bi` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_sumarios_turmas1`
    FOREIGN KEY (`turmas_tu_id` )
    REFERENCES `escola`.`turmas` (`tu_id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_sumarios_disciplinas1`
    FOREIGN KEY (`disciplinas_di_id` )
    REFERENCES `escola`.`disciplinas` (`di_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;
