DynamoDB is a managed key-value and document database that scales without servers to patch.
aws dynamodb create-table --table-name Orders \
--attribute-definitions AttributeName=customerId,AttributeType=S \
AttributeName=orderId,AttributeType=S \
--key-schema AttributeName=customerId,KeyType=HASH \
AttributeName=orderId,KeyType=RANGE \
--billing-mode PAY_PER_REQUEST --region ap-south-1
aws dynamodb put-item --table-name Orders \
--item '{"customerId":{"S":"c1"},"orderId":{"S":"o100"},"total":{"N":"499"}}'
aws dynamodb query --table-name Orders \
--key-condition-expression "customerId = :c" \
--expression-attribute-values '{":c":{"S":"c1"}}'
Key points:
- The partition key spreads data; the optional sort key orders items within it. Queries need the partition key.
- Design the table for your access patterns; there are no joins. Use a secondary index for another pattern.
- On-demand capacity suits unpredictable load; provisioned with auto scaling suits steady load.
- Turn on point-in-time recovery and use TTL to expire old items.