0

I just downloaded MySQL Workbench 5.2 and really like it. I created a database using New Connection and created my database like normal. I then created an EER Model and used the database. Then i edited some fields in my database (in the non EER model one) but the new data doesn't update in the EER Model. Is there a way that i can automatically update the data from the database in the EER Model without creating a new EER Model every time? Thanks

EDIT: Also is there a way to create a foreign key outside the EER Model interface. Or does it have to be done ther?? Thanks

dgilperez
  • 10,716
  • 8
  • 68
  • 96
NeXtMaN_786
  • 661
  • 2
  • 12
  • 23

2 Answers2

1

You must re-create the ER diagram based on the changes you made to your database. Workbench does not do this automatically (to my knowledge).

You can create foreign key constraints using the ALTER TABLE syntax. See the documentation:

InnoDB enables you to add a new foreign key constraint to a table by using ALTER TABLE:

ALTER TABLE tbl_name
    ADD [CONSTRAINT [symbol]] FOREIGN KEY
    [index_name] (index_col_name, ...)
    REFERENCES tbl_name (index_col_name,...)
    [ON DELETE reference_option]
    [ON UPDATE reference_option]
Kermit
  • 33,827
  • 13
  • 85
  • 121
  • thanks, is there a way to create a foreign key outside the EER Model interface. Or does it have to be done there? – NeXtMaN_786 Feb 21 '13 at 16:59
  • is there a way to do it without syntax?? By clicking on buttons and stuff? – NeXtMaN_786 Feb 21 '13 at 16:59
  • 1
    @NeXtMaN_786 You can do it by changing the table properties. There is a tab for foreign keys/relationships (don't remember exactly). You should really learn how to do it without a GUI. – Kermit Feb 21 '13 at 17:00
1

MySQL Workbench supports a two-way synchronization. Whenever you have changed something in your model or your database just use Database -> Synchronize Model to open the sync wizard which detects all changes and offers you a detail pane where you can select what to sync in which direction (if the default doesn't fit your needs).

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181
  • I wish this was automated, that would be cool. Is there any tool with ER model and automated sync? – Srneczek May 11 '16 at 18:22
  • Hello, nice info there! So we have Forward Engineer to create schema & tables etc from EER model, Reverse Engineer to create EER from existing schema & tables, and Synchronize Model to find and transfer Changes!!! Great Staff, not Automatic but still very helpful!!! THANKS – Apostolos55 Apr 27 '22 at 16:10