Answer the question
In order to leave comments, you need to log in
Online Store database on MongoDB. Is the author of this article contradicting himself or am I missing something?
Hello.
I'm learning MongoDB, building an online store using it.
On the Internet, I found an interesting article on the MongoDB blog on a suitable topic:
https://dzone.com/articles/product-catalog-part-1-...
According to the article, the author divided the product and its variants, so that the product is stored in collection in, say, `products` and its variants in `variants`.
He (the author) justified it like this:
One option is to store an item and all its variants together in a single document. This approach has the advantage of being able to retrieve an item and all variants in a single query. However, it is not the best approach in all cases. It is an important best practice to avoid unbounded document growth. If the number of variants and their associated data is small, it may make sense to store them in the item document.
Another option is to create a separate variant data model that can be referenced relative to the primary item:
It is an important best practice to avoid unbounded document growth.
These documents contain all of the information we need to do fast lookups of items in our catalog based on various search facets.
{
“_id”: “30671”,
“title”: “Evening Platform Pumps”,
“department”: “Shoes”,
“Category”: “Women/Shoes/Pumps”,
“price”: 149.95,
“attrs”: [“brand”: “Calvin Klein”, …],
“sattrs”: [“style”: ”Designer”, …],
“vars”: [
{
“sku”: “93284847362823”,
“attrs”: [{“size”: 6.0}, {“color”: “red”}, …],
“sattrs”: [{“width”: 8.0}, {“heelHeight”: 5.0}, …],
}, … //Many more SKUs
]
}
Answer the question
In order to leave comments, you need to log in
Databases, programming languages, frameworks do not need to be studied by articles. Articles are only hints, suggestions, suggestions for improvement, attempts to discuss the problem. There is fragmentary knowledge. For normal learning, take a monga course, for example, on pluralsight.com. Then you will get a complete strict and systematized system in your head of what you can and cannot do. You will see and be aware of all the possibilities of the subject being studied. And then you already look at articles on the Internet, and after courses and a little practice on them, you will even begin to understand that there are many articles on the Internet, with frank bullshit, confusing, from people who have not studied the subject normally, which are due to lack of knowledge and normal education invent pseudo-theories, innovations, bicycles, crutches and constructions built on fragmentary knowledge. Often, authors write articles to understand the issue themselves and get hints from the comments. I do that myself sometimes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question