M
M
MagnusDidNotBetray2020-09-08 17:41:26
MongoDB
MagnusDidNotBetray, 2020-09-08 17:41:26

Correct product catalog collection structure?

Good day. I am designing a database for an online clothing store, DBMS - MongoDB, the project itself is educational. I'm interested in how goods should be stored correctly, in terms of both requests being quickly executed, and that the requests themselves are not too complicated.
As I see it: there is a collection of products, it consists of such documents (each color is, in fact, a separate product):

{
    'id': 1,
    "gender": "male",
    "category": "jeans",
    "subcategory": "slim",
    "name": "Slim Jeans",
    "description": {
        "cardDescr": "",
        "shortDescr": "",
        "fullDescr": ""
    },
    "frontImage": "",
    "backImage": "",
    "otherImages": [],
    "color": "light indigo",
    "price": 6995,
    "sale": 0,
    "size": [
        {
            "waist": 28,
            "length": 28,
            "qty": 20
        },
        {
            "waist": 28,
            "length": 30,
            "qty": 25
        }
        //...
    ]
}

Does this option have the right to life? If not, then maybe it's better to create collections of categories and subcategories, and insert their id into products?
Thanks to all.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question