DVA-C02 practice question 22 of 35
A developer is creating an AWS Lambda function that searches for Items from an Amazon DynamoDQ table that contains customer contact information. The…
Full set: 598 questionsDomain Troubleshooting and Optimization
The requirement is to efficiently search for items by a specific customer-type and perform a partial-match search on the emailaddress. A DynamoDB Query operation is the most efficient method for this. A Query requires an equality condition on the partition key and can use a beginswith condition on the sort key. Since the table already exists, a Global Secondary Index (GSI) must be used, as Local Secondary Indexes (LSIs) can only be created when the table is created. By creating a GSI with customer-type as the partition key and emailaddress as the sort key, the Lambda function can issue a Query that efficiently filters by customer-type and then applies the beginswith operator to the emailaddress sort key to find partial matches.
B. A Query operation requires an exact match on the partition key. The beginswith condition cannot be used on a partition key, only on a sort key.
C. A Local Secondary Index (LSI) cannot be added to an existing DynamoDB table. It must be defined at the time of table creation, which violates the problem's constraint.
D. A Local Secondary Index (LSI) cannot be added to an existing table. Additionally, using job-title as the partition key does not align with the search requirement, which is based on customer-type.
1. AWS DynamoDB Developer Guide - Global Secondary Indexes: "Unlike local secondary indexes, you can create and delete global secondary indexes on an existing table." This supports the choice of a GSI over an LSI for an existing table. (See section: Global secondary indexes)
2. AWS DynamoDB Developer Guide - Working with Queries in DynamoDB: "The KeyConditionExpression parameter specifies the search criteria. You must specify the partition key name and value as an equality condition. You can optionally provide a second condition for the sort key." This confirms the structure of a Query. (See section: Query)
3. AWS DynamoDB Developer Guide - Condition Expressions: "The beginswith function is a supported key condition expression for the sort key attribute." This confirms that beginswith can be used on the sort key as proposed in the correct answer. (See section: Comparison Operator and Function Reference)
4. AWS DynamoDB Developer Guide - Local Secondary Indexes: "You can define a maximum of five local secondary indexes when you create a table." This confirms that LSIs must be created with the table and cannot be added later. (See section: Local secondary indexes)
Keep practicing
Take the free DVA-C02 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other DVA-C02 practice questions
- Question 1A company has a multi-node Windows legacy application that runs on premises. The applicat…
- Question 2A developer migrated a legacy application to an AWS Lambda function. The function uses a …
- Question 3A development learn has an Amazon API Gateway REST API that is backed by an AWS Lambda fu…
- Question 4A company is expanding the compatibility of its photo-snaring mobile app to hundreds of a…
- Question 5A company has an ecommerce application. To track product reviews, the company's developme…
- Question 6A social media company is designing a platform that allows users to upload data, which is…
