'Many to many relation table field into MongoDB
While doing a many to many relationship in SQL we create a table that will have the ID of the 2 tables that are forming the relationship. Sometimes in that table that we are creating, we put more data.
Example:
A table called worker and a table called department. Workers can work in many departments and many workers can work in the same department.
However the workers move between department and we need to store the year that they move into another department.
In mongoDB how can we represent that year. I am creating id for every worker and adding the department where they have worked but how do I store the year?
How to represente the WantedField.
Solution 1:[1]
one way that you could achieve this can be to just simply do the same thing in mongoDB, create another table just to save the relations of workers and departments.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | DreamWorld420 |

