0
0
DynamoDBquery~10 mins

When Scan is acceptable 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 perform a Scan operation on a DynamoDB table named 'Products'.

DynamoDB
response = dynamodb_client.[1](TableName='Products')
Drag options to blanks, or click blank then click option'
Ascan
Bget_item
Cquery
Dupdate_item
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'query' instead of 'scan' when you want all items.
Using 'get_item' which retrieves only one item by key.
2fill in blank
medium

Complete the code to add a filter expression to the Scan operation to only get items where 'Category' equals 'Books'.

DynamoDB
response = dynamodb_client.scan(TableName='Products', FilterExpression='[1] = :cat', ExpressionAttributeValues={':cat': {'S': 'Books'}})
Drag options to blanks, or click blank then click option'
AcategoryName
Bcategory
CCategory
DProductCategory
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'category' which does not match the attribute name.
Using a different attribute name not present in the table.
3fill in blank
hard

Fix the error in the Scan operation that tries to filter items by 'Price' less than 20.

DynamoDB
response = dynamodb_client.scan(TableName='Products', FilterExpression='Price [1] :val', ExpressionAttributeValues={':val': {'N': '20'}})
Drag options to blanks, or click blank then click option'
A!=
B<
C=
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' which is invalid for comparison in FilterExpression.
Using '==' which is not supported in DynamoDB expressions.
4fill in blank
hard

Fill both blanks to complete the Scan operation that retrieves items with 'Stock' greater than 0 and projects only 'ProductId' and 'Stock'.

DynamoDB
response = dynamodb_client.scan(TableName='Products', FilterExpression='Stock [1] :min', ExpressionAttributeValues={':min': {'N': '0'}}, ProjectionExpression='[2], Stock')
Drag options to blanks, or click blank then click option'
A>
B<
CProductId
DCategory
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' for the filter.
Projecting wrong attribute names.
5fill in blank
hard

Fill all three blanks to complete the Scan operation that paginates results using 'LastEvaluatedKey', filters items with 'Status' equal to 'Active', and projects 'UserId' and 'Status'.

DynamoDB
response = dynamodb_client.scan(TableName='Users', FilterExpression='Status = :stat', ExpressionAttributeValues={':stat': {'S': 'Active'}}, ProjectionExpression='[1], Status', ExclusiveStartKey=[2])
Drag options to blanks, or click blank then click option'
AUserId
Blast_key
C{}
DLastEvaluatedKey
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong attribute names in projection.
Passing wrong type or variable for ExclusiveStartKey.