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.
- Open the API Console and go to the Data Tab.
- Choose the
articletable on the left panel. - Click on the
Modifytab. - Click on the column name that you wish to add a foreign key constraint over (in this case,
author_id). - Check the
Foreign keycheckbox and choose your reference table and reference column (in this case,authorandidrespectively). - Hit
Save.
Was this page helpful?