The pivot table is the correct solution. You shouldn't have a column containing multiple ids. You can't index that and it will get slower and slower as the tables grow. You also can't use relationships or joins on them without a bunch of hacky workarounds because that's not how a relational database works.
Feb 18, 2019
3
Level 1
Laravel relationship suggestion
Hi.. i need a suggestion, i have a two tables articles and authors. my scenario is every article have more then one author. My problem is, how to get author data with article. i know the solution with belongsToMany relationship with pivot table. is there any solution without use pivot table. Thanks..
Article_table
---------------------------------------
| id | title | author_id |
---------------------------------------
| 1 | title 1 | 1,2 |
---------------------------------------
| 2 | title 2 | 3,4,5 |
---------------------------------------
Authors_table
-----------------------
| id | name |
-----------------------
| 1 | name 1 |
-----------------------
| 2 | name 2 |
-----------------------
| 3 | name 3 |
-----------------------
| 4 | name 4 |
-----------------------
Please or to participate in this conversation.