Circular reference causing error - how do I get around this?
Posted: Mon 13 Jun 2011 15:37
Hi.
We are trialling dbForge for possible adoption by our company. It all looks good so far except for one thing, which is the only black mark we have against the software.
Anyway: We are working with it on existing databases, which have so far been maintained awkwardly with a combination of phpMyAdmin and luck. One such database has two tables - call them A and B - which reference one another as foreign key.
Unfortunately, it doesn't seem like dbForge can cope with this. When we try to synchronise, it throws up errors for our analogues of these tables. It recommends reordering the build: but of course it is impossible to reorder the build correctly because you cannot both declare A before B and declare B before A.
As with the SQL above, the correct answer is to first create A and B, and then alter them to create the two foreign keys.
My question is, can I resolve this easily? I would prefer to have dbForge be aware of the two constraints, so the ideal solution to the problem would be simply to tell it to defer these constraints, or at least to somehow have the indices show up separately from the table itself in the build order dialogue.
Thanks in advance
We are trialling dbForge for possible adoption by our company. It all looks good so far except for one thing, which is the only black mark we have against the software.
Anyway: We are working with it on existing databases, which have so far been maintained awkwardly with a combination of phpMyAdmin and luck. One such database has two tables - call them A and B - which reference one another as foreign key.
Code: Select all
CREATE TABLE A (
id int auto_increment primary key,
id_b int auto_increment
);
CREATE TABLE B (
id int auto_increment primary key,
id_a int auto_increment
);
ALTER TABLE A ADD FOREIGN KEY (id_b) REFERENCES (B.id);
ALTER TABLE B ADD FOREIGN KEY (id_a) REFERENCES (A.id);
As with the SQL above, the correct answer is to first create A and B, and then alter them to create the two foreign keys.
My question is, can I resolve this easily? I would prefer to have dbForge be aware of the two constraints, so the ideal solution to the problem would be simply to tell it to defer these constraints, or at least to somehow have the indices show up separately from the table itself in the build order dialogue.
Thanks in advance