i have 2 tables namely users and employers . I would like to match them together like tinder style, which means that when both the user and the employer liked each other , they will each receive a notification .
However i am not sure how would the relationship
table will look like??
Right now what i have is in the Relationship
Table ,
1.user_id
2.target_employer_id
3.employer_id
4.target_user_id
If i am not wrong , this is considered as a Many - Many relationship. So , is this table correct???
As I understand your question, in your application, a user can like an employer, and an employer can like a user.
If this is right, it seems clear to me that there are two distinct (many to many) relationships (user => employer, employer => user), and that in your proposed table only two fields are filled at a time.
The best way to represent those relationships is to use two tables.
User to employer fields:
Employer to user fields:
Depending if you are using Laravel 4 or Laravel 5, you can use one of those two packages to generate the two pivot tables via a migration: