Full post: complete schema, sample data showing all 8 rows, every access pattern query, and ElectroDB entity definitions for all 3 entities.
https://t.co/TVGj5WxXvM
Pattern #2 in the library. Pattern #1 (SaaS multi-tenant) is linked at the bottom if you missed it.
E-commerce orders are deceptively hard to model in DynamoDB.
Orders have a lifecycle. They belong to customers. They contain items. And you need to query them 8 different ways.
Here's the schema I'd use in production. π§΅
The one thing that breaks at scale:
STATUS#pending becomes a hot partition when you're processing thousands of orders/second.
Fix: shard the status key.
Fan out, query all shards in parallel, merge client-side.
Don't add this until CloudWatch tells you to.
β Skip it when:
- Pre-PMF, patterns still evolving
- Multiple teams own different entity types
- Heavy reporting requirements
- < 6 access patterns
Follow along for:
- Weekly schema patterns
- DynamoDB design opinions
- Build-in-public updates
And sign up at https://t.co/fbTL6ZakYl to get early access when the tool launches.
I'm building https://t.co/fbTL6ZakYl β the visual DynamoDB schema designer that doesn't exist yet.
After building 5+ production apps on single-table DynamoDB, I'm tired of designing schemas in my head and translating them to code by hand.
Here's what I'm making and why π§΅
Before I build the tool, I'm publishing the patterns.
First up: SaaS Multi-Tenant β the most common DynamoDB schema.
4 entities. 3 GSIs. 10 access patterns. Full ElectroDB code.
https://t.co/Dz07pALu8c