I am trying to figure out how to effectively link my store database with the products it sells.
Currently I have each as a collection under the Store database. The schema looks like this
I am concentrating on stores that sell less than 100 items initially. Because of this low number of items that each store is going to sell I am inclined to embed the products in the store collection. If I do this, I can eliminate the product collection because the products that the store sells will be embedded.
If I embed the product as a subdocument, do I embed it as a document or as an object? say like this
“name”: “Product Name”
“short description” : “description”
“category tag”: [ “tag”, “tag”]
“price” : price
My confusion is that the relationship is a one to many. The product will have a one relationship and the store will have a many relationship.
The current way I have it set up is that I add the product and after I add it to the product collection, I add the _id of the product to the store record in a product array.