Richard210363
Richard210363

Reputation: 8406

In MySQL workbench's EER diagrams, where do I set the Foreign Key Constraint name?

When I create 2 child tables of a parent table and add foreign key fields into the child tables, MySQL Workbench EER gives the Foreign Key Constraint the same name as the field in the child table.

In each child table I am referencing the id field of the parent so would use the same sensible field name in both child tables.

However, this leads to 2 Foreign Key Constraints with the same name. Which is not allowed in MYSql.

For example,

a parent table:

User with an ID field as Primary key

2 child tables:

User_Address with a foreign key field of user_id

User_Orders with a foreign key field of user_id

This results with 2 Foreign Key Constraints called user_id

I realise I can edit the SQL during the Forward Engineer process but it seems to me that I should be able to edit the Foreign Key Constraints name in the GUI.

Is there a way to edit the Foreign Key Constraints name?

Upvotes: 1

Views: 1292

Answers (1)

Mike Lischke
Mike Lischke

Reputation: 53532

Open the table in the table editor (double click on the table figure) and switch to the foreign key tab:

enter image description here

Upvotes: 2

Related Questions