DynamoDB: Return multiple item or an Item?

Viewed 80

I have been reading about Best Practices for DynamoDB on AWS Documentation.

What I don't get why is it good idea to store multiple Items in the table for 1 Order for Order Detail and Product? I understand it is for access patterns to be searchable. Why not keep in a single item? For example:

{
  "Id": "AAA-BB-45555",
  "Email": "name@hotmail.com",
  "UserId": "425",
  "Name": "John Paul",
  "Total": "12.50",
  "Billing": {
    "Name": "John Paul",
    "Address": {
      "Address1": "line1...",
      "Address2": "line2..."
    }
  },
  "Products": [
    {
      "ItemId": "AAABB",
      "Name": "Product 1"
    },
    {
      "ItemId": "AAVVV",
      "Name": "Product 2"
    }
  ]
}

Query would return 1 Item of Order Detail (include Products), surely this is cheaper than having return multiple Items of Order Detail and Products?

0 Answers
Related