I am just confused about One-One relationship and Many-Many relationship. Well if I have a users table and a course table, Do I have to add a third table to make it Many-Many relationship or I can just connect them with foreign keys and primary keys? I hope my question is clear to you.
Difference between One-Mnay relationship & Many-Many relationship
71 views Asked by LastFox At
3
There are 3 answers
0
On
You are asking about many to many relationship. In this imaginary relation you have to follow following steps
1-create two tables(users,courses) 2-make third table which is called pivot table . that will contains the foreighn keys of both tables that shows the relation b/w two tables.
3-You also have to make relationships of one-to-many in both tables(users,courses).
I hope this helps if not visit this link you will understand.
https://onlinewebtutorblog.com/laravel-8-many-to-many-eloquent-relationship-tutorial/
One-to-Many example :-
Many to One example :-