Click to See Complete Forum and Search --> : MySQL Foreign Key


scaiferw
05-13-2008, 03:46 PM
I'm trying to create a server database, and at the moment am working on two tables; subnets and ip_addresses.

I want the subnet_name column from the subnets table to be the foreign key for the subnet column in the ip_addresses table.

When I try to create the table with a foreign key with MySQL Administrator, I get the following code:

CREATE TABLE `qanet`.`ip_addresses` (
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`subnet` VARCHAR(15) NOT NULL,
`ip_address` VARCHAR(15) NOT NULL,
`comment` VARCHAR(256) NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `FK_subnet_id` FOREIGN KEY `FK_subnet_id` (`subnet`)
REFERENCES `subnets` (`subnet_name`)
ON DELETE RESTRICT
ON UPDATE RESTRICT
)
ENGINE = InnoDB;

which returns the error;
MySQL Error Number 1005
Can't create table '.\qanet.ip_addreses.frm' (errno: 150)

I'm using MySQL v. 5.0.22.

A Google search only shows that a lot of people have had this problem, but is short on solutions that are applicable to this situation.

Does anyone have any idea where I've gone wrong?

chazzy
05-13-2008, 04:22 PM
the fact that it's referencing a file (.frm) indicates that the permissions on the relative directory structure for data (mysql_data or something similar) are wrong.