Banco de Dados Cinema
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `mydb` ;
-- -----------------------------------------------------
-- Table `mydb`.`ATOR`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`ATOR` ( `codigo` INT NOT NULL , `nome` VARCHAR(45) NULL , PRIMARY KEY (`codigo`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`CATEGORIA`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`CATEGORIA` ( `codigo` INT NOT NULL , `nome` VARCHAR(45) NULL , PRIMARY KEY (`codigo`) )
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`FILME`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`FILME` ( `codigo` INT NOT NULL , `nome` VARCHAR(45) NULL , `codigoCategoria` INT NULL , PRIMARY KEY (`codigo`) , INDEX `fk_FILME_CATEGORIA1_idx` (`codigoCategoria` ASC) , CONSTRAINT `fk_FILME_CATEGORIA1` FOREIGN KEY (`codigoCategoria` ) REFERENCES `mydb`.`CATEGORIA` (`codigo` ) ON DELETE NO ACTION ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`FILME_ATOR`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`FILME_ATOR` ( `codigoFilme` INT NOT NULL , `codigoAtor` INT NOT NULL , PRIMARY KEY (`codigoFilme`, `codigoAtor`) , INDEX `fk_FILME_ATOR_ATOR1_idx` (`codigoAtor` ASC) , CONSTRAINT `fk_FILME_ATOR_FILME1` FOREIGN KEY (`codigoFilme` ) REFERENCES `mydb`.`FILME` (`codigo` ) ON DELETE NO ACTION ON UPDATE NO ACTION,