Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

98 lines (80 sloc) 3.493 kB
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 `candidatos2010` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `candidatos2010`;
-- -----------------------------------------------------
-- Table `candidatos2010`.`estados`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `candidatos2010`.`estados` (
`idEstado` INT NOT NULL AUTO_INCREMENT ,
`sigla` VARCHAR(5) NOT NULL ,
`nome` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`idEstado`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `candidatos2010`.`cargo`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `candidatos2010`.`cargo` (
`idCargo` INT NOT NULL AUTO_INCREMENT ,
`nome` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`idCargo`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `candidatos2010`.`candidatos`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `candidatos2010`.`candidatos` (
`idCandidato` INT NOT NULL AUTO_INCREMENT ,
`nome` VARCHAR(200) NOT NULL ,
`nome_urna` VARCHAR(200) NOT NULL ,
`numero` VARCHAR(10) NOT NULL ,
`partido` VARCHAR(10) NOT NULL ,
`coligacao` VARCHAR(100) NOT NULL ,
`sqCand` VARCHAR(100) NOT NULL ,
`estados_idEstado` INT NOT NULL ,
`cargo_idCargo` INT NOT NULL ,
PRIMARY KEY (`idCandidato`, `estados_idEstado`, `cargo_idCargo`) ,
CONSTRAINT `fk_candidatos_estados`
FOREIGN KEY (`estados_idEstado` )
REFERENCES `candidatos2010`.`estados` (`idEstado` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_candidatos_cargo`
FOREIGN KEY (`cargo_idCargo` )
REFERENCES `candidatos2010`.`cargo` (`idCargo` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_candidatos_estados` ON `candidatos2010`.`candidatos` (`estados_idEstado` ASC) ;
CREATE INDEX `fk_candidatos_cargo` ON `candidatos2010`.`candidatos` (`cargo_idCargo` ASC) ;
-- -----------------------------------------------------
-- Table `candidatos2010`.`bens`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `candidatos2010`.`bens` (
`idBem` INT NOT NULL AUTO_INCREMENT ,
`nome` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`idBem`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `candidatos2010`.`candidatos_bens`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `candidatos2010`.`candidatos_bens` (
`idCandidato` INT NOT NULL ,
`idBem` INT NOT NULL ,
PRIMARY KEY (`idCandidato`, `idBem`) ,
CONSTRAINT `fk_candidatos_bens_candidatos`
FOREIGN KEY (`idCandidato` )
REFERENCES `candidatos2010`.`candidatos` (`idCandidato` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_candidatos_bens_bens`
FOREIGN KEY (`idBem` )
REFERENCES `candidatos2010`.`bens` (`idBem` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_candidatos_bens_candidatos` ON `candidatos2010`.`candidatos_bens` (`idCandidato` ASC) ;
CREATE INDEX `fk_candidatos_bens_bens` ON `candidatos2010`.`candidatos_bens` (`idBem` ASC) ;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
Jump to Line
Something went wrong with that request. Please try again.