Reputation: 31
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.
Upvotes: 0
Views: 74
Reputation: 284
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/
Upvotes: 0
Reputation: 1
Teacher teaches students is one to many relationship And students learning from the teacher is many to one relationship May be your dought is clear now!!
Upvotes: 0