Relational data storage in MongoDB (NoSQL)

I'm trying to figure out NoSQL, and I see the benefits of embedding data in documents.

What I can’t understand, and I hope someone can clarify, is how to store data if it should be relational.

For instance.

I have many users. They all buy the product. Therefore, every time they buy a product, we add it to the user document in mongo, so its built-in and all this is great.

The problem that arises with me is when something about this product changes.

Suppose user A buys a car called Porsche. Then add a link to the link under the user profile. However, in a strange turn of events, Porsche acquires Ferrari.

What are you doing now, updating each entry and changing the name from Porsche to Ferrari?

Usually in SQL we create 3 tables. One for users, one for cars (description, model, etc.) and one for mapping users to purchases.

Do you do the same for Mongo? It seems that if you go down this route, you are trying to get Mongo to do something in the SQL way, and that’s not what it is for.

I can understand how certain data is great for embedding (addresses, contact details, comments, etc.), but what happens when you need to reference data that can and should change on a regular basis?

I hope this question is clear.

+3
source share
1 answer

DBRefs/Manual . , , - , . . mongoDB.

Mongo

, , , .

+2

Source: https://habr.com/ru/post/1674632/


All Articles