ACID Flashcards

1
Q

Which of the following is the best definition of an ACID transaction? (Select one.)

A

c. A group of database operations that must happen all together or not at all.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which of the following scenarios require the use of an ACID transaction? (Select all that apply.)

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which of the following statements are true about multi-document transactions in MongoDB? (Select all that apply.)

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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.)

A

b. Nadia does need to use a transaction in this scenario because multi-document operations are NOT inherently atomic in MongoDB.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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.)

A

b. commitTransaction()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which of the following commands will output to the shell if they are successful?

A

b. .commitTransaction()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly