How do I add a foreign key in SequelPro?

Padraig picture Padraig · Sep 3, 2013 · Viewed 21.3k times · Source

I'm using Sequel Pro 0.9.9.1 Build 3408.

I want to add a foreign key to a table and also on delete cascade.

I can't find anything in the GUI that allows me to add foreign keys.

Anyone know how to do this?

Answer

Stephen O'Flynn picture Stephen O'Flynn · Sep 5, 2013

You can either declare your table completely in SQL, and just add it that way.

Or you can declare the columns in the table so that it is defined. Then select the table and click on Relations. Using the + at the end of the screen will allow you to specify a table and column and if you want cascade behaviour on the update/delete.

The image below may help orient you, it's a bit crude but hopefully shows you where to click.

enter image description here