Examples / Data model diagrams
E-commerce data model
The core tables of an online store: customers, products and variants, carts, orders and their lines, payments and shipments, with keys and how they relate.
- Data model diagram
- Postgres
- SQL
Open in Plotix
A copy you can edit, or ask the agent to change.
Plotix's agent drew it from this request
Draw an entity relationship data model of an online store: customer, address, product, product variant, cart, cart item, order, order line, payment, shipment. Show key fields and cardinality.
What's in it
- Customer
PK id: uuid · email: text (unique) · name: text · created_at: timestamp - Address
PK id: uuid · FK customer_id: uuid · street, city: text · postal_code, country: text - Product
PK id: uuid · name: text · description: text · base_price: decimal - Product Variant
PK id: uuid · FK product_id: uuid · sku: text (unique) · price: decimal - Cart
PK id: uuid · FK customer_id: uuid · status: enum · updated_at: timestamp - Cart Item
PK id: uuid · FK cart_id: uuid · FK variant_id: uuid · quantity: int - Order
PK id: uuid · FK customer_id: uuid · status: enum · total: decimal - Order Line
PK id: uuid · FK order_id: uuid · FK variant_id: uuid · quantity, unit_price - Payment
PK id: uuid · FK order_id: uuid · method: text · amount, status - Shipment
PK id: uuid · FK order_id: uuid · carrier: text · tracking_no: text
How the parts connect
- Customer → Address has
- Customer → Cart owns
- Customer → Order places
- Cart → Cart Item contains
- Product Variant → Cart Item chosen in
- Product → Product Variant has variants
- Order → Order Line consists of
- Product Variant → Order Line sold as
- Order → Payment paid by
- Order → Shipment shipped by
More on data model diagrams.
Related examples
OAuth login with PKCESequence · How a single-page app signs a user in with OAuth 2.0 authorization code and PKCE, from th…
Stripe checkout and webhookFlow · The steps from a cart to a paid order with Stripe Checkout, including the webhook that co…
Serverless API on AWSDeployment · Where a serverless web API runs on AWS: CloudFront and S3 for the site, API Gateway and L…