Set Up the Foreign Key
Learn and practiceforeign key setup to create a relationship on a model.
We'll cover the following
The listings on the website are not tied to any users yet. Users don’t want to see other peoples’ listings, so we’ll use a foreign key to keep track of which users created which listings.
A foreign key is a way to create a relationship in a model. In our case, the relationship is between the listings and the users. Each listing will belong to a specific user who created the listing.
Listings linked to a user
Get hands-on with 1400+ tech skills courses.