Skip to main content
In this walkthrough you’ll create and use a simple DynamoDB table to persist e-commerce orders. The example demonstrates table design, capacity options, inserting and querying items (including PartiQL), editing items, and safe deletion practices. Scenario: when a customer places an order we need durable storage. For this demo we create a table named “Orders” to store each order record. You may choose a different name in your environment.

Table design: keys and access patterns

When creating a DynamoDB table you must choose a partition key, and optionally a sort key. These keys determine how items are grouped and how you should query them efficiently (Query vs Scan). Good key choices enable point queries and range queries without expensive scans. For this demo:
  • Partition key: customerId (String) — fetch all orders for a specific customer.
  • Sort key: orderId (String) — uniquely identifies an order for a given customer and enables ordering or range queries.
Use Query operations (requires partition key) to retrieve items efficiently. Reserve Scan for one-off or exploratory tasks only.
Partition key decides the logical grouping of items. The composite key (partition key + sort key) must be unique per item. Table design in DynamoDB is broad — study partition/sort key patterns and when to use Query vs Scan. See the official AWS DynamoDB documentation for best practices.
Screenshot of the AWS DynamoDB "Create table" console showing a form to create a table named "orders" with partition key "customerId" and optional sort key "orderId". The page also displays table settings options below.
Example: primary keys used in this demo

Table classes and capacity modes

Choose a table class and capacity mode based on access patterns and cost. Table classes: Capacity mode options: If you enable auto scaling, configure:
  • Minimum capacity units — lower bound the table can scale down to.
  • Maximum capacity units — upper bound the table can scale up to.
  • Target utilization — target percentage (for example, 70%) that drives autoscaling decisions.
Screenshot of the AWS DynamoDB console showing the "Read/write capacity settings" page with Capacity mode (On‑demand or Provisioned), read/write auto-scaling controls (minimum/maximum capacity units and target utilization), and a section for secondary indexes.
The console also shows estimated monthly costs for selected capacity and encryption options. You can enable server-side encryption using an AWS managed key (default) or a customer managed key (CMK). Deletion protection is available to reduce accidental deletions.
A screenshot of the AWS Management Console showing DynamoDB table creation settings, including estimated read/write capacity (5 RCU and 5 WCU, $2.91/month). The page also shows encryption-at-rest key management options and a deletion protection section for the table.

After table creation

Once created the table will typically become Active in a few seconds. Open the table to review configuration, keys, capacity mode, item count, and other metrics.
A screenshot of the AWS DynamoDB console showing the "orders" table overview. It displays general info like partition key (customerId), sort key (orderId), capacity mode (Provisioned) and table status (Active).
Indexes, monitoring, backups, streams, global tables, point-in-time recovery, and exports are accessible from the table tabs. The Monitoring tab surface CloudWatch metrics such as consumed read/write capacity, throttled requests, and latency.
A screenshot of the AWS DynamoDB console showing monitoring dashboards for a table named "orders," with charts for read/write usage, throttled requests, and latency. The left sidebar displays DynamoDB menu items (Dashboard, Tables, Backups, Exports to S3, etc.).

Insert items (Console, CLI, or SDK)

You can insert items using the console, AWS CLI, or any AWS SDK. Items must include the primary key attributes (customerId, orderId) and can include arbitrary additional attributes (for example price, delivered, items, createdAt, etc.). For this demo, add these example items via the console:
  • customerId = CUST-1, orderId = ORDER-10, price = 100, delivered = True
  • customerId = CUST-1, orderId = ORDER-2, price = 50, delivered = True
  • customerId = CUST-2, orderId = ORDER-30, price = 35, delivered = False
Screenshot of the AWS DynamoDB "Create item" form. It shows attributes with values: customerId = CUST-1 (partition key), orderId = ORDER-10 (sort key), price = 100, and delivered = True.
CLI example: insert a single item with put-item (JSON attributes must be passed in string or file form). Example format:

Query vs Scan — efficient retrieval

Prefer Query when you know the partition key. Query can also include sort key conditions (e.g. range queries) and non-key filters. Important: filter expressions are applied after DynamoDB reads matching items, so filtered-out items still consume read capacity units. Console example: fetch all orders for CUST-1. To further restrict results by price use a Filter condition such as price > 60. PartiQL (SQL-like) example to fetch all orders for CUST-1 with price greater than 60:
Note: PartiQL maps to underlying DynamoDB operations (Query/Scan) and follows the same capacity-cost semantics as the equivalent API calls.

Edit and delete items

To edit an item in the console: select the item → Edit item → change attribute values → Save. Example: update price from 100 to 120.
A screenshot of the AWS DynamoDB console showing the "Edit item" form for an "orders" table with attributes: customerId = CUST-1, orderId = ORDER-10, delivered = False, and price = 100. The UI shows options to add/remove attributes and buttons to save or cancel.
To delete an item: use Item actions → Delete item. To delete the whole table: Table actions → Delete, then confirm. If deletion protection is enabled you must disable it first.
Deleting a DynamoDB table is irreversible. If you need to retain data, create backups or enable point-in-time recovery before deleting.
After you submit a delete request the Tables list will show the table status as Deleting until the operation completes.
A screenshot of the AWS DynamoDB console showing the Tables page with a single table named "orders." A green banner at the top confirms the delete request and the table's status is shown as "Deleting."

Quick checklist: console workflow

  1. Create table — choose primary key(s), table class, and capacity mode.
  2. Review encryption and enable deletion protection if desired.
  3. Insert items (console, CLI, or SDK).
  4. Use Query or PartiQL for efficient lookups (avoid Scan).
  5. Monitor CloudWatch metrics and configure autoscaling if provisioned.
  6. Backup or enable point-in-time recovery before any destructive actions.
  7. Delete items or the table when finished (be mindful of deletion protection).

Watch Video

Practice Lab