The Importance of Data Values ​​Using the NOSQL Approach?

I am almost ready to work on a large application; a couple of days ago I saw Martin Fowler talk about "NOSQL". After that, I realized that I was using Mongo as a relational db, so I decided to reorganize my schema. But I heard a lot about honesty from a guy coming from the world of RDBMS; I really understand how important this is, and can data integrity be achieved in the NOSQL engine?

To be more explicit, here is a simple example:

Let's say I have the essence product, inventoryin my system,

and in my product definition inventorylink product_id,

and currently inventoryin my mongo collection it looks like this:  {'inventory' :{'product_id' : '1', 'count' : 15}}

So, I can save inventory, like this on my system:
{'inventory' :{'product' : {'id' : 1, 'name' : 'book'}, 'count' : 15}}
and still achieve data integrity? What if I change the name of the product _id : 1in the object product, then what happens - will there be a cycle for updating all collections inventory?

+4
source share
1 answer

MongoDB does not have built-in functions that provide consistency (only an exception: uniqueness restrictions can be applied with unique indexes). The obligation not to write inconsistent data to the database is delegated to the application.

( MongoDB, ), , , , . , , .

, . , update {multi:true} .

:

 db.collection.update(
     {
         "inventory.product.id": "1"
     },
     {
         $set: { "inventory.product.name": "New Product Name" }
     },
     {
          multi: true
     }
);

, , , . , , $.

+5

All Articles