Adding a foreign key constraint to table column

If many records will refer to the same data, it is more efficient and less error prone to update a single record and keep references to it in other places. That’s where foreign key constraints come in. The foreign key constraint will ensure consistency of data and no overheads on update.

In this section, we will show how to add a foreign key constraint over a column. Consider a sample schema with an article and an author table. Lets try to add a foreign key constraint over the author_id column of the article table.

  1. Open the API Console and go to the Data Tab.
  2. Choose the article table on the left panel.
  3. Click on the Modify tab.
  4. Click on the column name that you wish to add a foreign key constraint over (in this case, author_id).
  5. Check the Foreign key checkbox and choose your reference table and reference column (in this case, author and id respectively).
  6. Hit Save.
../../../../_images/adding-fk.png