Collisions in MongoDB

0

In relational databases like Oracle if I am making a transaction: Does this have a backpoint, so that if there was a problem the changes are not made in the database? Can this be done in some way in Mongo? Are there also transactions in Mongo?

    
asked by John Kevin Barrera 24.01.2018 в 15:45
source

2 answers

1

In response to your question and adding a bit of theory:

Relational databases usually guarantee the ACID properties related to the reliability with which transactions are processed (both read and write). MySQL and PostgreSQL (among many more) are examples of databases that provide these properties.

  • Atomicity requires that each transaction be executed on its total or fails without any change being applied.
  • The consistency requires that the database only pass from one state valid to the next, with no intermediate points.
  • The isolation requires that if transactions are executed simultaneously, the result is equivalent to its execution in series. A transaction can not see the partial result of the application of another.
  • Durability means that the result of a transaction compromised is permanent, even if the database is blocked immediately or in case of a loss of energy.

What you point to is how MongoDB manages atomicity, for which I should first tell you that:

  

In MongoDB, a write operation is atomic at the level of a   only document, even if the operation modifies multiple documents   embedded in a single document.

     

When a single write operation modifies multiple documents,   the modification of each document is atomic, but the operation as   A whole is not atomic and other operations can be interspersed.

     

(Excerpted from the MongoDB documentation)

Therefore, MongoDB provides only one transaction in the entire document: writes are never partially applied to an inserted or updated document. The operation is atomic in the sense that it fails or succeeds, for the document as a whole. To finalize and summarize , MongoDB if it has a "backpoint", will only save the data, if the transaction was successful, if there was an error it will return to its previous state (Backpoint).

    
answered by 24.01.2018 в 16:32
0

They recently announced the roadmap for Mongodb 4.0 and 4.2 in which they include multidocument transactions (only for replicaSet in 4.0 and also for sharding in version 4.2). just as the relational bases do (even with a very similar syntax)

I'll leave you a couple of links in case you're interested:

link link

    
answered by 21.02.2018 в 13:40