Circular reference causing error - how do I get around this?

Discussion of open issues, suggestions and bugs regarding database management and administration tools for MySQL
Post Reply
Altreus
Posts: 3
Joined: Mon 13 Jun 2011 15:23

Circular reference causing error - how do I get around this?

Post by Altreus » 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.

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);
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

.jp
Devart Team
Posts: 345
Joined: Wed 09 Sep 2009 06:55
Location: devart

Post by .jp » Tue 14 Jun 2011 06:21

Please answer the following questions:
1) What version of MySQL Server are you using?
2) Which build of dbForge Studio for MySQL are you using (you can find this information on the About window)?
3) Which edition of dbForge Studio for MySQL are you using (trial of express)?
4) In what functionality did you find this problem, in Schema Comparer or Database Project?

Altreus
Posts: 3
Joined: Mon 13 Jun 2011 15:23

Post by Altreus » Tue 14 Jun 2011 07:58

1) MySQL Server version: 5.0.77
2) 5.0.33
3) Trial
4) It was while trying to build a project, but the same happens when running the Schema Comparer so I guess this is the first thing the project builder runs.

Thank you :)

Viktor
Devart Team
Posts: 68
Joined: Thu 06 May 2010 08:12

Post by Viktor » Tue 14 Jun 2011 13:21

Please check if the "Load completions from database" option is checked (Tools->Options->Text Editor->Code Completion).
After checking the "Load completions from database" option, reopen the connection and try to synchronize your databases.

Altreus
Posts: 3
Joined: Mon 13 Jun 2011 15:23

Post by Altreus » Tue 14 Jun 2011 13:30

The box is already ticked.

Viktor
Devart Team
Posts: 68
Joined: Thu 06 May 2010 08:12

Post by Viktor » Fri 17 Jun 2011 15:13

Please download a new build. The latest build if 5.0.36. We have released it today.
We made lots of fixes in it. Please download the latest version and check whether the error persists.

Post Reply