In a database, a foreign key is a field that references another table.
They keep track of related records and which table they exist in. They also let you know what record they relate to, which means updating them is simple and quick.
In this tutorial, I show how you can add a foreign key while creating table using migration in CodeIgniter 4.