DataGrip & MySQL: One-to-Many Foreign Keys

I am having some issues with foreign keys. My database currently has (3) tables: message_queue, message_queue_data, and ew_transactions.

In this setup “message_queue” is the primary database, and its primary_key is message_queue_id.

“message_queue_data” the primary_key is message_queue_data_id and it also has message_queue_id which is a foreign key with the message_queue_id primary_key of the “message_queue_ table. This key is visible in the foreign keys of the ”message_queue_data" table.

In “ew_transactions” the primary_key is ew_transaction_id and I also have a message_queue_id which I am trying to also make a foreign key relation with the message_queue_id of “message_queue”; however, it is saying that is a duplicate key. 

When I've used MySQLWorkbench in the past I have been able to setup one-to-many foreign keys. does it just want the keys to have a unique name in each table? Or am I missing something here?

Any help is greatly appreciated.

Thank you!

1 comment

As far as I remember, having multiple FKs that reference the same PK in another table is only possible if the FKs are in the same table.


Please sign in to leave a comment.