0
0
DynamoDBquery~10 mins

TransactWriteItems in DynamoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start a transaction write with multiple operations.

DynamoDB
response = client.transact_write_items(TransactItems=[1])
Drag options to blanks, or click blank then click option'
A{'Put': {'TableName': 'MyTable', 'Item': {'Id': {'S': '123'}}}}
BNone
C['Put', 'Update']
D[{'Put': {'TableName': 'MyTable', 'Item': {'Id': {'S': '123'}}}}]
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a single dictionary instead of a list.
Using a list of strings instead of dictionaries.
2fill in blank
medium

Complete the code to add a condition expression to a Put operation in TransactWriteItems.

DynamoDB
TransactItems=[{'Put': {'TableName': 'MyTable', 'Item': {'Id': {'S': '123'}}, 'ConditionExpression': [1]]
Drag options to blanks, or click blank then click option'
A"attribute_exists(Name)"
B"Id = 123"
C"attribute_not_exists(Id)"
D"Id > 100"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a condition that checks for attribute existence instead of non-existence.
Using invalid syntax for the condition expression.
3fill in blank
hard

Fix the error in the TransactWriteItems call by completing the missing parameter.

DynamoDB
client.transact_write_items(TransactItems=[1])
Drag options to blanks, or click blank then click option'
A[{'Delete': {'TableName': 'MyTable', 'Key': {'Id': {'S': '123'}}}}]
B[{'Delete': {'Key': {'Id': {'S': '123'}}}}]
C[{'Delete': {'TableName': 'MyTable'}}]
D[{'Delete': {'TableName': 'MyTable', 'Key': {}}}]
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the Key parameter.
Providing an empty Key dictionary.
4fill in blank
hard

Fill both blanks to create a transaction with a Put and an Update operation.

DynamoDB
TransactItems=[{'Put': {'TableName': [1], 'Item': {'Id': {'S': '001'}}}}, {'Update': {'TableName': [2], 'Key': {'Id': {'S': '002'}}, 'UpdateExpression': 'SET #n = :val', 'ExpressionAttributeNames': {'#n': 'Name'}, 'ExpressionAttributeValues': {':val': {'S': 'NewName'}}}}]
Drag options to blanks, or click blank then click option'
A'Users'
B'Orders'
C'Products'
D'Inventory'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same table name for both operations when different tables are intended.
Omitting quotes around table names.
5fill in blank
hard

Fill all three blanks to create a transaction with Put, Update, and Delete operations with conditions.

DynamoDB
TransactItems=[{'Put': {'TableName': [1], 'Item': {'Id': {'S': '100'}}}}, {'Update': {'TableName': [2], 'Key': {'Id': {'S': '101'}}, 'UpdateExpression': 'SET Age = :age', 'ExpressionAttributeValues': {':age': {'N': '30'}}, 'ConditionExpression': [3], {'Delete': {'TableName': 'Logs', 'Key': {'LogId': {'S': 'log123'}}}}]
Drag options to blanks, or click blank then click option'
A'Customers'
B'Employees'
C"attribute_exists(Age)"
D"attribute_not_exists(Age)"
Attempts:
3 left
💡 Hint
Common Mistakes
Using attribute_not_exists in the Update condition when attribute_exists is required.
Mixing up table names between operations.