I think you are struggling with the separation of object / object modeling using database schema modeling. I also struggled with this when I tried to try MongoDb.
For semantics and clarity, I'm going to replace Groups with the word Categories
Essentially, your theoretical model is a many-many relationship, since each Item can belong to Categories , and each Category can then have many Items .
This is best handled when modeling domain objects, and not in the database schema, especially when implementing a document database (NoSQL). In your MongoDb schema, you fake many-many relationships using a combination of top-level document models and embeddings.
Embedding is hard to master for people coming from SQL constants, but is an integral part of the answer. A trick determines whether it is shallow or deep, one-sided or two-sided, etc.
Top Level Document Models
Since your Category documents contain some of their data and largely refer to a huge number of Items , I agree with you that their full embedding inside each Item unreasonable.
Instead, treat Item and Category objects as top-level documents. Make sure your MongoDb schema allocates a table for each of them, so that each document has its own ObjectId .
The next step is to decide where and how much to embed ... there is no right answer, since it all depends on how you use it and what your scaling ambitions are ...
Investment Solutions
1. Elements
At a minimum, your Item objects must have a collection property for their categories. At the very least, this collection should contain an ObjectId for each Category .
My suggestion would be to add to this collection, the data that you use when interacting with Item most often ...
For example, if I want to list a bunch of elements on my web page in a grid and show the names of the categories in which they belong. Obviously, I donโt need to know everything about Category , but if I have a built-in ObjectId, a second query is required to get any details about it.
Instead, itโs most advisable to embed the Category Name property in the collection along with the ObjectId , so disabling the Item can now display its category names without another request.
The most important thing to remember is that the key / value objects embedded in your Item that "represent" a Category must not match the actual model of the Category document ... This is not OOP or relational database modeling.
2. Categories
Otherwise, you can refuse to embed in one direction and have no Item information in your Category documents ... or you can add a collection for the item data as described above ( ObjectId , or ObjectId + Name ) ...
In this direction, I personally would be inclined to ensure that nothing is implemented ... more than likely, if I want Item information for my category, I want it a lot, more than just a name ... and deep introduction of a document (document ) top level does not make sense. I just put up with a database query for the Items collection, where each of them had an ObjectId of my category in its category collection.
Uh ... confused for sure. The fact is that you will have some data duplication, and you will need to configure your models to use for better performance. The good news is that MongoDb and other document databases are good at ...