Scenario Overview

Imagine you have an e-commerce website where customers place orders for different items. The website relies on Amazon DynamoDB and it requires logging of all events from when an order is placed until the item is delivered.

Website Requirements:

  • The status of orders placed on your website can be ACTIVEPLACEDCOMPLETE or CANCELLED.
  • You need to keep the current view of customers’ orders on the main database table used by your application.
  • Each order has a status attribute and contains a list of one or more items.

In JSON format, an item on the orders table has the following attributes.

{
    "id": "string",
    "status": "string",
    "customer": {
        "id": "string",
        "address": "string",
        "name": "string",
        "phone": "string"
    },
    "orderDate": "YYYY-MM-DD hh:mm:ss",
    "shipDate": "YYYY-MM-DD hh:mm:ss",
    "items": [
        {
            "id": "string",
            "name": "string",
            "price": "string",
            "quantity": "string",
            "status": "string"
        }
    ]
}

You will implement a solution to meet this requirement by using two DynamoDB tables - Orders and OrdersHistory; and a streaming solution to copy item level changes from the Orders table to OrdersHistory table.