An application stores payroll information nightly in DynamoDB for a large number of employees across
hundreds of offices. Item attributes consist of individual name, office identifier, and cumulative daily hours.
Managers run reports for ranges of names working in their office. One query is. “Return all Items in this office
for names starting with A through E”.
Which table configuration will result in the lowest impact on provisioned throughput for this query?
A.
Configure the table to have a hash index on the name attribute, and a range index on the office identifier
B.
Configure the table to have a range index on the name attribute, and a hash index on the office identifier
C.
Configure a hash index on the name attribute and no range index
D.
Configure a hash index on the office Identifier attribute and no range index
Office Id is unique for each office. So Office id must be used as Partition(hash) key. There can be same named emplyoees across different offices. So employee name cannot be hash key.. but can be used as range(sort) key.
Agreeish…
B
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.CoreComponents.html#HowItWorks.CoreComponents.PrimaryKey
…
In a table that has a partition (hash) key and a sort (range) key, it is possible for two items to have the same partition (hash) key value—however, those two items must have different sort key values.
…
My 2 Cents:
Office ID is not Unique; each office will have multiple employees and each employee is going to have a row in the table. Therefore the Office value will repeat. This is fine for the Hash/Partition key. There better not be two Jane Doe employees in a single office either or the space/time continuum may collapse (unless they do Jane Doe 1 and so forth).
Do your part and protect the space/time by not allowing 2 employees with the same name to work in the same office.
B.
Configure the table to have a range index on the name attribute, and a hash index on the office identifier