exam questions

Exam AWS Certified Developer Associate All Questions

View all questions & answers for the AWS Certified Developer Associate exam

Exam AWS Certified Developer Associate topic 1 question 140 discussion

Exam question from Amazon's AWS Certified Developer Associate
Question #: 140
Topic #: 1
[All AWS Certified Developer Associate Questions]

A developer is designing an Amazon DynamoDB table for an application. The application will store user information that includes a unique identifier and an email address for each user. The application must be able to query the table by using either the unique identifier or the email address.
How should the developer design the DynamoDB table to meet these requirements?

  • A. For the primary key of the table, specify the unique identifier as the partition key and specify the email address as the sort key.
  • B. For the primary key of the table, specify the unique identifier as the partition key. Create a local secondary index (LSI) based on the email address.
  • C. For the primary key of the table, specify the email address as the partition key and specify the unique identifier as the sort key.
  • D. For the primary key of the table, specify the unique identifier as the partition key. Create a global secondary index (GSI) based on the email address.
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
aws_leo
Highly Voted 2 years, 7 months ago
Selected Answer: D
The main point in the question is that they want to query table by using EITHER unique identifier OR email address. A and B is not enough if we only has one primary key in a table Assump that we configure base table has partition key is "unique identifier" so that we can query base on this key For B), the LSI index must have the same partition key with base table. So in case the assumption above, you cannot query only email address For D) the GSI can have different partition key and sort key from base table. So we can create partition key is "email address" and sort key is "unique identifier" for GSI. Then we can use only "email address" for query
upvoted 8 times
...
SD_CS
Most Recent 1 year, 5 months ago
Selected Answer: D
The partition key must be also decided by the query pattern. The query can happen with the unique if or the email address. So its best to keep the unique id as the partition key of the primary table. However this will not solve the requirement of querying with the email address. So create a GSI with Email as the partition key. This cannot be LSI because the LSI can not have a different partition key, just a different sort key.
upvoted 1 times
...
rcaliandro
2 years ago
Selected Answer: D
To design the indexes we have to study the table. The table is composed by an unique identifier and by an email. We can notice that both of the fields are unique and are optimal to partition the table. So, in both cases we don't need a sort key because will be unuseful (doesn't make sense to order only one row). So we can create the primary key using the userID as partition key. Regarding the second query, doesn't make sense to create a LSI because the partion key is shared with the primary key. Instead, we have to create a GSI by using the email address (also in this case we don't need the sort key because the email is unique). So, D is the correct answer
upvoted 1 times
...
Rpod
2 years, 2 months ago
Selected Answer: D
D - Query for LSI will require to specify the partition key with email since its an index local to that partition and we are required to query by email id which means we are required to retreive records which exist in multiple partitions .
upvoted 1 times
...
captainpike
2 years, 3 months ago
What's the difference between implementing A and D? I thought setting up A you would always get an index, A. For the primary key of the table, specify the unique identifier as the partition key and specify the email address as the sort key.) D. For the primary key of the table, specify the unique identifier as the partition key. Create a global secondary index (GSI) based on the email address.
upvoted 1 times
shahs10
2 years, 3 months ago
A means we are querying based on unique identifier and sorting based on email address while D means we can query based on both unique identifier and email address
upvoted 1 times
...
...
aarti_k
2 years, 4 months ago
Selected Answer: D
The correct answer is D. I initially thought it is B but no. LSI is alternate sort key , we want to search using either of the keys, so GSI GSI --> provides you option to define alternate primary key
upvoted 2 times
...
sichilam
2 years, 5 months ago
In general, you should use global secondary indexes rather than local secondary indexes. The exception is when you need strong consistency in your query results, which a local secondary index can provide but a global secondary index cannot (global secondary index queries only support eventual consistency).
upvoted 1 times
...
sichilam
2 years, 5 months ago
Global Secondary index It is D
upvoted 1 times
...
Dirisme
2 years, 5 months ago
Selected Answer: D
The Query operation in Amazon DynamoDB finds items based on primary key values.
upvoted 1 times
...
AulaitQM
2 years, 9 months ago
Selected Answer: D
It is D. At first I thought it was B, but the requirement is to be able to search by one or the other, the unique id or the email. With a local index, you need the primary key as well. Only a global index would allow you to search using only the email (once the primary key is set to the unique id)
upvoted 4 times
...
Spamuel
2 years, 9 months ago
Selected Answer: D
Option D - https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-indexes-general.html
upvoted 3 times
...
Jabol
2 years, 9 months ago
Selected Answer: D
We need different primary key in second index so we need global secondary index
upvoted 3 times
...
peyto
2 years, 10 months ago
question sucks its trying to convey this: GSI can be a single attribute key which is called a partition key or it can be a composite key with two attributes,
upvoted 2 times
Spamuel
2 years, 9 months ago
Agreed - https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-indexes-general.html
upvoted 1 times
...
...
Chhotu_DBA
2 years, 10 months ago
Selected Answer: D
I think its D
upvoted 3 times
m_t_kd
2 years, 10 months ago
Pls specify reason
upvoted 1 times
Dipak25
1 year, 6 months ago
We don't need a sort key here. Becuase both unique_id and email_id are unique for each row. For LSI partition key will be same as partition key of the table only sort key will differ. But our requirement is to query by both. So have unique_id as base table partition key and email_id as the GSI partition key is the approach.
upvoted 1 times
...
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...