0
0
DynamoDBquery~10 mins

Why Scan reads the entire table in DynamoDB - Test Your Understanding

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
BQuery
CGetItem
DPutItem
Attempts:
3 left
💡 Hint
Common Mistakes
Using Query instead of Scan will not read the entire table.
GetItem retrieves a single item, not the whole table.
2fill in blank
medium

Complete the code to add a filter expression to the Scan operation to reduce the items returned.

DynamoDB
response = dynamodb_client.scan(TableName='Products', FilterExpression=[1])
Drag options to blanks, or click blank then click option'
ACondition('Category', 'Books')
BKey('Category').eq('Books')
CKeyConditionExpression('Category = Books')
DAttr('Category').eq('Books')
Attempts:
3 left
💡 Hint
Common Mistakes
Using Key instead of Attr in FilterExpression.
Using KeyConditionExpression in Scan, which is only for Query.
3fill in blank
hard

Fix the error in the Scan code that tries to use KeyConditionExpression.

DynamoDB
response = dynamodb_client.scan(TableName='Products', [1]=Key('Category').eq('Books'))
Drag options to blanks, or click blank then click option'
AKeyConditionExpression
BFilterExpression
CConditionExpression
DExpressionAttributeValues
Attempts:
3 left
💡 Hint
Common Mistakes
Using KeyConditionExpression in Scan causes an error.
Confusing Query and Scan parameters.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps product names to their prices from a Scan response.

DynamoDB
prices = {item['[1]']: item['[2]'] for item in response['Items']}
Drag options to blanks, or click blank then click option'
AProductName
BPrice
CCategory
DStock
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Category' or 'Stock' instead of 'ProductName' or 'Price'.
Mixing up keys and values in the dictionary.
5fill in blank
hard

Fill all three blanks to create a Scan call that reads the entire table with a limit and returns only the 'ProductName' attribute.

DynamoDB
response = dynamodb_client.scan(TableName='Products', [1]=5, [2]='[3]')
Drag options to blanks, or click blank then click option'
ALimit
BProjectionExpression
CProductName
DFilterExpression
Attempts:
3 left
💡 Hint
Common Mistakes
Using FilterExpression instead of ProjectionExpression to select attributes.
Not setting Limit to control read size.