should the id always be the foreign key ?
Posted: Sun Apr 23, 2017 2:47 pm
I have a table Admin(should have actully named it articles
) with the following fields:
And Then i have the Tags table with the following feilds:
Now i want to create a hasMany relationship between the Admin and the Tags table. How do i do this ? I mean which field in the Admin table will be the foreign key ? i believe usually the foreign key is always the ID field , even the docs show the same: HERE --> https://laravel.com/docs/5.4/migrations ... onstraints , or should can i make the tag feild in the Admin table as the foreign key to the ID in the Tags table ?
I still have a scrambled brain about this issue and hence i taught it would be best to ask here, can somebody please give me a bit more clarity on this topic ?
Thank you.
Gautam.
Code: Select all
ID
title
keywords
blog_content
tag
filePath
slug
created_at
updated_atCode: Select all
Id
tagI still have a scrambled brain about this issue and hence i taught it would be best to ask here, can somebody please give me a bit more clarity on this topic ?
Thank you.
Gautam.