I'm designing a mongo database and I have a dilemma if I should go for normalization. Let's say that there is a database with images and descriptions. Many alternative descriptions can belong to one image, but only one is assigned as the main one. When I fetch a document for a given Image, I need to have only the main description. Besides that, I need to have some statistics about the description (all of them, not only the main ones), so I will be executing on them some aggregations.
I consider three designs:
- To have only one collection called "images" with embedded descriptions. The fetching would be fast and straightforward, but I'm not sure if it is efficient to run aggregates on the nested documents.
- Put the descriptions into a separate collection and store the id of the main one in each image document. The data would be normalized and I can run aggregations on the collection, but I also have to do one more query for each image to get the corresponding description.
- Combine the two above and store all descriptions in a dedicated collection, but at the same time embed the main one in the corresponding image document.
Thank you for any suggestions.