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.
Asked
Active
Viewed 62 times
3 Answers
1

kundan
- 44
- 3
-
I understand this, but how about making tables? Do I need to add 3rd table to control the other 2 or just I can assign foreign keys in one table and primary keys in the other one? – LastFox Aug 02 '21 at 09:53
-
My point of view, we will go for primary & foreign key relationship. But it's depend upon project complexity & requirements. – kundan Aug 02 '21 at 10:00
0
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!!

Iamjahnvi
- 1
- 1
0
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/

Waqas Yousaf
- 264
- 4
- 13