I come from a MySQL background and am trying to wrap my head around MongoDB. In particular, I'm struggling to conceptualize how I should model n:n relationships the "Mongo way."
For this example, let's say we have two collections: users and interests. We need to be able to represent or query for several things in our data:
- User's interests
- User's rating of interest, e.g. "like" or "dislike"
- Users with a given interest
- Counter (which can be incremented/decremented) of each rating of the interest
- Interest name
In MySQL, I would have created a users_interests table indexed on both user IDs and interest IDs. For the counter, I would have had separate columns for each rating type, and each time a user rated/un-rated an interest, done a transaction to ensure that the counts were never false.
I've tried reading about some schema designs, but to no avail.
Can you help a lost soul find the way?