Problem Description: For example, there is a team table in the relational database, a user table, the two are many-to-many relationships, that is, a team can have multiple user, a user may belong to more than one team, how does such a relationship in MongoDB storage?
If it is a pair of more, I know can be nested, but do not know how to deal with many-to-many relationships, please advise. "From the mountain Thief" question answer: How to deal with a lot of relationships is the essence of NoSQL. In theory, storage can be done in a single collection, but in practice this is a rare situation. This is due to the diversity of queries, if there is only one type of query, then this many-to-many relationship in a well-designed set, although there will be a lot of redundancy, but the efficiency must be the highest. The key to how to design such a database is to see how many queries you have, how often each one is, and what other requirements are used. For different queries, the performance of the same database design is a big difference. There is also a point, generally do not split into three sets, this is the traditional relational database thinking mode. It's a nosql thing to think about in a different way. The common scenario is to split into two collections and then have a portion of redundancy to index the most commonly used queries. This has to be practiced. "Mars" 1, Team inside a teammates: [] Save user's _id or other index value, so that you know what a Team has user
2, the user can check the team's find ({teammates: _id}), so that a user in which team "ideal" and the relational database similar, separate two document storage,
Then one of the document's ID lists exists in another document "Jarod"
How MongoDB handles many-to-many relationships