Templates/Commerce

Orders, single table (DynamoDB) database schema

Customers, orders and order lines in one table keyed by PK and SK, with a GSI for orders by status.

1 tables, 0 references

Opens as a new diagram you can change. Free.

Tables

shop

One table: CUSTOMER#<id> holds the profile (SK PROFILE), its orders (SK ORDER#<date>#<id>) and each order's lines (SK LINE#<order>#<n>).

  • PKS not null
  • SKS not null
  • typeS not null
  • emailS
  • nameS
  • statusS
  • totalN
  • placedAtS
  • skuS
  • quantityN
  • addressM
  • address.line1S
  • address.postcodeS
  • GSI1PKS
  • GSI1SKS

As AWS CLI script

The diagram also exports CloudFormation template, AWS CDK (TypeScript), Terraform, Sample items (BatchWriteItem, one request per line).

#!/bin/sh
# Orders, single table (DynamoDB): DynamoDB tables. Needs the AWS CLI signed in to the target account and region.
set -e

# shop
# Other attributes, not declared to DynamoDB: type (S), email (S, optional), name (S, optional), status (S, optional), total (N, optional), placedAt (S, optional), sku (S, optional), quantity (N, optional), address (M, optional), address.line1 (S, optional), address.postcode (S, optional), GSI1PK (S, optional), GSI1SK (S, optional)
aws dynamodb create-table --cli-input-json '{"TableName":"shop","BillingMode":"PAY_PER_REQUEST","AttributeDefinitions":[{"AttributeName":"PK","AttributeType":"S"},{"AttributeName":"SK","AttributeType":"S"},{"AttributeName":"GSI1PK","AttributeType":"S"},{"AttributeName":"GSI1SK","AttributeType":"S"}],"KeySchema":[{"AttributeName":"PK","KeyType":"HASH"},{"AttributeName":"SK","KeyType":"RANGE"}],"GlobalSecondaryIndexes":[{"IndexName":"GSI1","KeySchema":[{"AttributeName":"GSI1PK","KeyType":"HASH"},{"AttributeName":"GSI1SK","KeyType":"RANGE"}],"Projection":{"ProjectionType":"ALL"}}]}'
aws dynamodb wait table-exists --table-name 'shop'

More Commerce templates

Start with one diagram, free

One diagram with two branches, no card needed. Upgrade when your team needs more.