MySQL Forums
Forum List  »  InnoDB

Foreign Key Different Database
Posted by: Ray Garrison
Date: April 27, 2007 08:52AM

I don't know if I am trying to do something that is not supported, or if I'm just making an error.

Does InnoDB support a foreign key relationship between databases?

Can I do this?

USE database1;
CREATE TABLE sometable ( id INT NOT NULL, somevalue TEXT, PRIMARY KEY (id) ) TYPE=InnoDB;

USE database2;
CREATE TABLE anotherone ( id INT NOT NULL, sometable_id INT, anothervalue TEXT, PRIMARY KEY (id), KEY (sometable_id), FOREIGN KEY (sometable_id) REFERENCES database1.sometable (id) ) TYPE=InnoDB;


When I try this, I get the standard "a foreign key constraint fails" error, but I don't know whether that's because the key migration across different databases isn't supported, or because I have a missing key value in the reference table, or some other problem.

Why would I want to do this? I am using a CRM system that creates it's own database, I have a different application that has it's own database, I am anticipating that for performance reasons I might want these databases on separate CPU's in a MySQL cluster, and besides I don't want to co-mingle the different databases because of support issues.

Options: ReplyQuote


Subject
Views
Written By
Posted
Foreign Key Different Database
18065
April 27, 2007 08:52AM


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.