6
Good night, you guys.
As Mongodb changes a lot our way of modeling a database, I came across a question that can be up to half beast.
I’m doing a Restful API using Lumen and Mongodb as a database, and I want to create a collection of product categories, and these categories have their respective mother and daughter categories. As in the example below:
- mother category
- daughter category
- daughter category
- daughter category
- daughter category
- daughter category
- mother category
- daughter category
- daughter category
- daughter category
What would be the most correct way to outline this in a single collection? Or the most correct way would be to somehow place these categories within the product collection?
The right thing depends on the business model. A type of X structure may not be suitable for an X business model, but it may be the best option for a Y model. The question of how it is, becomes broad and susceptible to responses based on opinions.
– Daniel Omine
Just to help, search on "adjacency" and "nested". Example in this article: http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/
– Daniel Omine
From the link you suggested I was able to reformulate my question to google, and not to my surprise, the answer was in the Mongodb documentation itself. I will post as an answer to this question to help others. Thanks.
– Marcos Kubis