MySQL Forums :: Newbie :: Error 1005 Errno 150


Advanced Search

Error 1005 Errno 150
Posted by: Lee Bornstein ()
Date: April 19, 2012 07:49PM

Have 3 tables

Departments
Primary Key Dept_ID

Budgets
Primary Key Bud_ID
Linked to Departments by Dept_ID

Transactions
Primary Key Trans_ID
Linked to Budgets by Bud_ID

Unable to create Budgets Table - I get error 1005 errno 150

Please take a look at my Tables and see if you can help me get past this error.

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

-- -----------------------------------------------------
-- Table `TRIMS_SQL_Data`.`Budget_Transactions`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `TRIMS_SQL_Data`.`Budget_Transactions` (
`Trans_ID` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`Bud_ID` INT UNSIGNED NOT NULL ,
`Descr` CHAR(30) NOT NULL ,
`Reference` CHAR(10) NULL ,
`Invoice` CHAR(14) NULL ,
`Date` DATE NOT NULL ,
`Src` CHAR(1) NOT NULL ,
`OpenItem` TINYINT(1) NULL ,
`Amount` DECIMAL(19,4) NOT NULL ,
`Closed` CHAR(1) NULL ,
`Tsrc` CHAR(1) NULL ,
`Tsrn` INT UNSIGNED NULL ,
PRIMARY KEY (`Trans_ID`) ,
UNIQUE INDEX `Trans_ID_UNIQUE` (`Trans_ID` ASC) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `TRIMS_SQL_Data`.`Budget_Master_File`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `TRIMS_SQL_Data`.`Budget_Master_File` (
`Bud_ID` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`Sequence` INT UNSIGNED NOT NULL ,
`Dept_ID` INT UNSIGNED NOT NULL ,
`AccountNo` CHAR(15) NOT NULL ,
`Descr` CHAR(30) NOT NULL ,
`Type` TINYINT(4) NOT NULL ,
`MstSub` CHAR(1) NULL ,
`EjGr` CHAR(1) NULL ,
`OpenOrders` DECIMAL(19,4) NULL ,
`Budget` DECIMAL(19,4) NULL ,
`BudgetLY` DECIMAL(19,4) NULL ,
`BudgetPY` DECIMAL(19,4) NULL ,
PRIMARY KEY (`Bud_ID`) ,
UNIQUE INDEX `Bud_ID_UNIQUE` (`Bud_ID` ASC) ,
UNIQUE INDEX `AccountNo_UNIQUE` (`AccountNo` ASC) ,
CONSTRAINT `fk_Budget_Master_File_Budget_Transactions`
FOREIGN KEY (`Bud_ID` )
REFERENCES `TRIMS_SQL_Data`.`Budget_Transactions` (`Bud_ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `TRIMS_SQL_Data`.`Budget_Departments`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `TRIMS_SQL_Data`.`Budget_Departments` (
`Dept_ID` INT NOT NULL ,
`Descr` CHAR(30) NOT NULL ,
PRIMARY KEY (`Dept_ID`) ,
UNIQUE INDEX `Dept_ID_UNIQUE` (`Dept_ID` ASC) ,
CONSTRAINT `fk_Budget_Departments_Budget_Master_File`
FOREIGN KEY (`Dept_ID` )
REFERENCES `TRIMS_SQL_Data`.`Budget_Master_File` (`Dept_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;


Error occurs when buliding table...
Any help is appreciated.



-> `BudgetPY` DECIMAL(19,4) NULL ,
-> PRIMARY KEY (`Bud_ID`) ,
-> UNIQUE INDEX `Bud_ID_UNIQUE` (`Bud_ID` ASC) ,
-> UNIQUE INDEX `AccountNo_UNIQUE` (`AccountNo` ASC) ,
-> CONSTRAINT `fk_Budget_Master_File_Budget_Transactions`
-> FOREIGN KEY (`Bud_ID` )
-> REFERENCES `TRIMS_SQL_Data`.`Budget_Transactions` (`Bud_ID` )
-> ON DELETE NO ACTION
-> ON UPDATE NO ACTION)
-> ENGINE = InnoDB;
ERROR 1005 (HY000): Can't create table 'trims_sql_data.budget_master_file' (errn
o: 150)
mysql>
mysql>

Options: ReplyQuote


Subject Written By Posted
Error 1005 Errno 150 Lee Bornstein 04/19/2012 07:49PM
Re: Error 1005 Errno 150 Barry Galbraith 04/19/2012 09:02PM
Re: Error 1005 Errno 150 Lee Bornstein 04/20/2012 08:14AM


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.