ACID Flashcards
Which of the following is the best definition of an ACID transaction? (Select one.)
c. A group of database operations that must happen all together or not at all.
Which of the following scenarios require the use of an ACID transaction? (Select all that apply.)
Updating a bank database to reflect the transfer of money from Customer A’s bank account into Customer B’s bank account.
Updating inventory and shopping cart records when a customer adds an item to their online shopping cart in an ecommerce app.
Which of the following statements are true about multi-document transactions in MongoDB? (Select all that apply.)
a. Database operations that affect more than one document, like .updateMany(), are not inherently atomic in MongoDB and must be completed by using a multi-document transaction in order to have ACID properties.
b. Multi-document transactions should be treated as a precise tool that is used only in certain scenarios.
c. Using a multi-document transaction with a MongoDB database ensures that the database will be in a consistent state after running a set of operations on multiple documents.
Nadia needs to update customer account balances across multiple collections in MongoDB. It’s important that the database operations used in this transaction adhere to ACID properties. Should Nadia use a transaction in this scenario? (Select one.)
b. Nadia does need to use a transaction in this scenario because multi-document operations are NOT inherently atomic in MongoDB.
You are creating a transaction that does the following:
Inserts a new savings account into the accounts collection for an existing customer Funds the new savings account with $200 from their checking account
The transaction looks like this:
const session = db.getMongo().startSession()
session.startTransaction()
const account = session.getDatabase(‘bank’).getCollection(‘accounts’)
account.insertOne({
account_id: “MDB361428849”,
account_holder: “Donna Wood”,
account_type: “savings”,
balance: 200.0,
transfers_complete: [],
last_updated: new Date()
})
account.updateOne( { account_id: “MDB919841472” }, {$inc: { balance: -200.00 }})
What method should you use to complete this transaction? (Select one.)
b. commitTransaction()
Which of the following commands will output to the shell if they are successful?
b. .commitTransaction()