How to create a foreign key relationship in phpMyAdmin?

Member

by gilbert , in category: Third Party Scripts , 9 months ago

How to create a foreign key relationship in phpMyAdmin?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by raphael_tillman , 9 months ago

@gilbert 

To create a foreign key relationship in phpMyAdmin, follow these steps:

  1. Open phpMyAdmin and select the database in which you want to create the foreign key relationship.
  2. Click on the "Structure" tab to view the list of tables in the selected database.
  3. Select the table that you want to add the foreign key to by clicking on it.
  4. In the table view, click on the "Relation View" icon. It looks like a key symbol.
  5. In the "Add foreign constraint" section, select the column that you want to use as the foreign key from the drop-down menu. This is the column in the current table that will reference a column in another table.
  6. In the "Referenced table" field, select the table that you want to reference with the foreign key. This is the table that contains the primary key that the foreign key will reference.
  7. In the "Referenced column" field, select the column in the referenced table that the foreign key will reference. This is typically the primary key column.
  8. Click on the "Save" button to create the foreign key relationship.


phpMyAdmin will then create the foreign key relationship between the selected table and the referenced table, based on the columns and tables you specified.