MySQL Forums
Forum List  »  InnoDB

ERROR 1005: Can't create table (errno: 150) :: InnoDB
Posted by: Thomas Rasoarahona
Date: July 10, 2008 08:29AM

Hi !

I create a database with workbench and when i import it in mysql there is this error. I read in a lot of messages that it is a fk problem but after looking for it in the sql code for hours i really don't see it. Can you help me please.

Thank you.

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 `mydb` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `mydb`;

-- -----------------------------------------------------
-- Table `mydb`.`language`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`language` ;

CREATE TABLE IF NOT EXISTS `mydb`.`language` (
`idlangues` TINYINT UNSIGNED NOT NULL ,
`Language_Name` VARCHAR(10) NOT NULL ,
PRIMARY KEY (`idlangues`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`Accomodation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Accomodation` ;

CREATE TABLE IF NOT EXISTS `mydb`.`Accomodation` (
`idAccomodation` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`language_idlangues` TINYINT UNSIGNED NOT NULL ,
`description_idlangues` VARCHAR(2000) NULL ,
`libelle_idlangues` VARCHAR(200) NULL ,
`id_xml` INT UNSIGNED NOT NULL ,
`name_acc` VARCHAR(250) NOT NULL ,
`type_acc` VARCHAR(45) NOT NULL ,
`nb_stars` TINYINT UNSIGNED NOT NULL ,
`main_pict_type` VARCHAR(20) NOT NULL ,
`main_pict_url` VARCHAR(200) NOT NULL ,
PRIMARY KEY (`idAccomodation`) ,
INDEX fk_Accomodation_language (`language_idlangues` ASC) ,
INDEX fk_Accomodation_language1 (`description_idlangues` ASC) ,
INDEX fk_Accomodation_language2 (`libelle_idlangues` ASC) ,
CONSTRAINT `fk_Accomodation_language`
FOREIGN KEY (`language_idlangues` )
REFERENCES `mydb`.`language` (`idlangues` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Accomodation_language1`
FOREIGN KEY (`description_idlangues` )
REFERENCES `mydb`.`language` (`idlangues` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Accomodation_language2`
FOREIGN KEY (`libelle_idlangues` )
REFERENCES `mydb`.`language` (`idlangues` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`Price`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Price` ;

CREATE TABLE IF NOT EXISTS `mydb`.`Price` (
`idPrice` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`Price_euros` FLOAT UNSIGNED NOT NULL ,
`fixe` TINYINT UNSIGNED NOT NULL ,
`board` TINYINT UNSIGNED NOT NULL ,
PRIMARY KEY (`idPrice`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`time`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`time` ;

CREATE TABLE IF NOT EXISTS `mydb`.`time` (
`idtime` INT NOT NULL AUTO_INCREMENT ,
`time_idPrice` INT UNSIGNED NOT NULL ,
`begin` DATE NOT NULL ,
`end` DATE NOT NULL ,
`duration` MEDIUMINT UNSIGNED NOT NULL ,
`duration_min` MEDIUMINT UNSIGNED NOT NULL ,
`duration_max` MEDIUMINT UNSIGNED NOT NULL ,
PRIMARY KEY (`idtime`) ,
INDEX fk_time_Price (`time_idPrice` ASC) ,
CONSTRAINT `fk_time_Price`
FOREIGN KEY (`time_idPrice` )
REFERENCES `mydb`.`Price` (`idPrice` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`Product`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Product` ;

CREATE TABLE IF NOT EXISTS `mydb`.`Product` (
`idProduct` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`Product_idAccomodation` INT UNSIGNED NOT NULL ,
`language_idlangues` TINYINT UNSIGNED NOT NULL ,
`name_idlangues` VARCHAR(50) NOT NULL ,
`time_idtime` INT NOT NULL ,
`quantity_idtime` INT UNSIGNED NOT NULL ,
`Product_idPrice` INT UNSIGNED NULL ,
`capacity` TINYINT UNSIGNED NOT NULL ,
PRIMARY KEY (`idProduct`) ,
INDEX fk_Product_language (`language_idlangues` ASC) ,
INDEX fk_Product_language1 (`name_idlangues` ASC) ,
INDEX fk_Product_Accomodation (`Product_idAccomodation` ASC) ,
INDEX fk_Product_time (`time_idtime` ASC) ,
INDEX fk_Product_time1 (`quantity_idtime` ASC) ,
INDEX fk_Product_Price (`Product_idPrice` ASC) ,
CONSTRAINT `fk_Product_language`
FOREIGN KEY (`language_idlangues` )
REFERENCES `mydb`.`language` (`idlangues` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Product_language1`
FOREIGN KEY (`name_idlangues` )
REFERENCES `mydb`.`language` (`idlangues` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Product_Accomodation`
FOREIGN KEY (`Product_idAccomodation` )
REFERENCES `mydb`.`Accomodation` (`idAccomodation` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Product_time`
FOREIGN KEY (`time_idtime` )
REFERENCES `mydb`.`time` (`idtime` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Product_time1`
FOREIGN KEY (`quantity_idtime` )
REFERENCES `mydb`.`time` (`idtime` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Product_Price`
FOREIGN KEY (`Product_idPrice` )
REFERENCES `mydb`.`Price` (`idPrice` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `mydb`.`Photos`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Photos` ;

CREATE TABLE IF NOT EXISTS `mydb`.`Photos` (
`idPhotos` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`Photos_idAccomodation` INT UNSIGNED NULL ,
`photo_type` VARCHAR(10) NOT NULL ,
`photo_url` CHAR(250) NOT NULL ,
`photo_taille` VARCHAR(10) NOT NULL ,
PRIMARY KEY (`idPhotos`) ,
INDEX fk_Photos_Accomodation (`Photos_idAccomodation` ASC) ,
CONSTRAINT `fk_Photos_Accomodation`
FOREIGN KEY (`Photos_idAccomodation` )
REFERENCES `mydb`.`Accomodation` (`idAccomodation` )
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;

Options: ReplyQuote


Subject
Views
Written By
Posted
652958
March 24, 2005 01:20PM
5999
October 09, 2012 09:48PM
4159
December 19, 2011 10:13PM
ERROR 1005: Can't create table (errno: 150) :: InnoDB
18084
July 10, 2008 08:29AM
9732
May 09, 2006 06:01PM
12961
November 15, 2006 02:05PM
7855
T D
February 01, 2008 06:47AM
9847
August 27, 2008 08:08AM
10163
December 03, 2008 10:15AM
6617
May 01, 2009 07:39AM
3897
August 29, 2011 04:46PM
5545
s l
December 15, 2009 01:48PM
5415
December 22, 2009 02:54AM
3654
February 18, 2011 08:55AM
4445
May 24, 2011 10:11AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.