A foreign key is a field that is used to establish the relationship between two tables via the primary key (You can also use a non-primary field but not recommended).
In this tutorial, I show how you can add a foreign key constraint while creating a table using migration in the Laravel 9 project.