Reputation: 87
I'm current developing a professional site for my organization whereby i have the following models:
employee id employee_no full_name skill id name sector id name field id name sector_id
The relationship are as following:-
as you can see the relationship there is many to many between
employee & skill, employee & sector and employee & fields
so i created three tables to handle these relationships the tables are as following:
employe_skill
id
employee_id
skill_id
employe_sector
id
employee_id
sector_id
employee_field
id
employee_id
filed_id
From the above you may see three tables but almost have the similarity. I need help on how to convert this relationship to polymorphic where i can have only one table.
Upvotes: 1
Views: 49
Reputation: 105
Despite the similarity between skill
and sector
the model you propose with three joining tables is completely valid. If the entities differs enough in an conceptual level, different models are completely justified.
Would recommend to create an Entity Relationship diagram to pinpoint the consistency of the system.
Here is how to implement those many to many relationships easily in Laravel.
Good luck!
Upvotes: 1