AWS Certified Database - Specialty | Optimal DynamoDB Data Model for Sales Application

Optimal DynamoDB Data Model for Sales Application

Question

A sales application stores inventory of available items for purchase.Each item is uniquely identified by its Part Number, and contains additional attributes: Part Type, Manufacture Date, Manufacturer Name, Country of Origin, and Cost.

The application requires to retrieve item information during each sales transaction.

Further, it produces reports for a list of sales for each country.

What would be the optimal DynamoDB data model for this application?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Answer: C.

Option A is incorrect because Manufacture Date is a poor choice for the partition key as it is a low cardinality attribute.

It results in a hot partition for all items manufactured on that date.

Option B is incorrect because Country of Origin is a low cardinality attribute resulting in a hot partition for the GSI.

Option C is CORRECT because Part Number is unique for each item, thus making it a good choice for the table partition key.Using a random prefix for the GSI partition key and County of Origin as the sort key enables high cardinality for the partition key (thus avoiding any hot partitions) while still allowing for fast querying on Country of Origin.

Option D is incorrect because Manufacture Date is a poor choice for the partition key of the GSI.

It is a low cardinality attribute resulting in a hot partition for all items manufactured on that date.

Reference:

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-partition-key-uniform-load.html https://aws.amazon.com/blogs/database/choosing-the-right-dynamodb-partition-key/

Based on the requirements of the sales application, the optimal DynamoDB data model should provide fast and efficient retrieval of item information during each sales transaction and generate reports for a list of sales for each country.

Let's review each option:

A. Table Partition Key=Manufacture Date; Table Sort Key=Part Number; GSI Partition Key= Manufacturer Name; GSI Sort Key=Country of Origin; In this option, the partition key is Manufacture Date, which may not be unique for each item. Therefore, there may be hot partitions, which can affect performance. The sort key is Part Number, which is unique for each item. The GSI partition key is Manufacturer Name, which may not be unique, and the GSI sort key is Country of Origin, which may not be the best option for generating reports for a list of sales for each country.

B. Table Partition Key=Part Number; Table Sort Key=Part Type; GSI Partition Key=Country of Origin; GSI Sort Key=Manufacturer Name; In this option, the partition key is Part Number, which is unique for each item, and the sort key is Part Type. This model allows for efficient retrieval of item information during each sales transaction. The GSI partition key is Country of Origin, which allows for generating reports for a list of sales for each country. The GSI sort key is Manufacturer Name, which can provide additional filtering options for the reports.

C. Table Partition Key=Part Number; Table Sort Key=Part Type; GSI Partition Key=Random Prefix; GSI Sort Key=Country of Origin; In this option, the partition key is Part Number, which is unique for each item, and the sort key is Part Type. However, the GSI partition key is a random prefix, which may not be useful for the sales application's requirements. The GSI sort key is Country of Origin, which is useful for generating reports for a list of sales for each country.

D. Table Partition Key=Part Number; Table Sort Key=Part Type; GSI Partition Key= Manufacture Date; GSI Sort Key=Country of Origin; In this option, the partition key is Part Number, which is unique for each item, and the sort key is Part Type. The GSI partition key is Manufacture Date, which may not be unique for each item and may lead to hot partitions. The GSI sort key is Country of Origin, which is useful for generating reports for a list of sales for each country.

Therefore, option B is the optimal DynamoDB data model for this sales application as it allows for efficient retrieval of item information during each sales transaction and provides useful filtering options for generating reports for a list of sales for each country.