V
V
Viktor Novikov2018-12-11 18:08:46
MongoDB
Viktor Novikov, 2018-12-11 18:08:46

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:

In particular, this sentence caught my attention:

It is an important best practice to avoid unbounded document growth.

Here the author means, if I understood him correctly, that it is necessary to prevent the uncontrolled growth of the document.
Actually, at this stage there are no questions. They come up next.
Further, the author proposes to create a `summaries` collection, which will store all the necessary (for example, for searching) information about the product, including its variants:

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
    ]
}

Actually, it is `summaries` that causes me the most questions. Why in the first case, the author separated the product and its variants, justifying this by the fact that he wants to prevent uncontrolled growth of the document, and in the second case, in `summaries` he does the opposite?
Maybe I didn’t understand the article correctly, maybe I still don’t understand something, I admit it, because I just started learning MongoDB.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Mazhekin, 2018-12-12
@YourDesire

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 question

Ask a Question

731 491 924 answers to any question