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
- E-commerce storeCustomers, products and categories, orders with line items, and addresses.
- Multi-vendor marketplaceSellers with listings, buyer orders split per seller, payouts and reviews.
- Inventory & warehousesStock levels per warehouse, stock movements, suppliers and purchase orders.
- Point of saleStores, registers and staff ringing up sales with mixed payments.
- Restaurant orderingMenus with items and modifiers, and orders for dine-in or takeaway.
- Food deliveryCustomers order from restaurants; couriers pick up, deliver and get rated.
- Promotions & couponsCampaigns issuing coupon codes, with redemption tracking against orders.
- Product catalogue with variantsProducts with options (size, colour), variants, images and nested categories.
- Subscription boxMonthly boxes, what goes in each, subscribers and their shipments.
- AuctionsAuctions with lots, timed bids, watchers and winners.
- Product catalogue (MongoDB)Products with embedded variants and images, categories and reviews that reference them.
Start with one diagram, free
One diagram with two branches, no card needed. Upgrade when your team needs more.