E-commerce Database Schema database schema
The E-commerce Database Schema database schema is a DB Planner template with 36 tables, 236 columns and 46 relationships, free to use. Core tables include brands, cart_items, carts, categories. It can be opened as an interactive diagram or exported as PostgreSQL, MySQL, or MSSQL DDL.
- Tables
- 36
- Columns
- 236
- Relationships
- 46
- Category
- E-commerce
- Exports
- DBML, SQL, C#
- Price
- Free
What this schema models
A production-grade e-commerce database schema you can copy, fork and ship. 36 tables, 12 enums and 46 relationships covering the full online-store lifecycle: customer accounts and address books, a brand and category catalog, product options that generate SKU-level variants, multi-warehouse inventory, cart, checkout, orders, partial shipments, RMA returns, refunds, payments, discount codes, gift cards, and shipping and tax configuration. WHAT MAKES THIS DIFFERENT FROM A TOY EXAMPLE Most e-commerce ER diagrams you find online model products and orders and stop. This one models the parts that actually break in production: - Product variants done properly. products is the marketing item; product_variants is the sellable, stockable unit that carries the SKU and price. product_options and product_option_values define the axes (Size, Colour), and variant_option_values pins each variant to exactly one value per axis, so "Medium + Blue" resolves to a single row. Carts, orders, wishlists and stock all reference the variant, never the product. - Order snapshots. order_lines copy sku, title and unit price rather than joining live, and order_addresses freeze the shipping address at checkout. Renaming a product or editing your address book can never rewrite what an old invoice says was bought. - Partial fulfilment. shipments and shipment_lines let one order ship as several parcels from several warehouses, with shipped quantities summing to at most the ordered quantity. - Inventory as a ledger. inventory_movements is append-only with a signed quantity, so inventory_items.on_hand is a cached running total that can always be rebuilt and audited. - Money as integers. Every amount is stored in minor units. Tax is basis points, so 8.25 percent is 825. No floats anywhere. - Refunds as their own rows, never subtracted from the original payment. Gift cards use the same signed-ledger shape as stock. WHAT YOU GET Clean DBML that imports straight into DB Planner, plus a laid-out board where cards are colour-coded by zone — shopper, catalog, variants, inventory, cart, orders, fulfilment, reverse flow, money, promotions and configuration — with sticky notes explaining the design decision behind each group. Every table carries a Note explaining why it exists. Postgres-flavoured types (uuid, timestamptz, char(3) currency codes) that translate cleanly to MySQL or SQL Server. WHO IT IS FOR Developers designing an online store backend, students who need a realistic e-commerce ER diagram for coursework, teams migrating off Shopify or WooCommerce to something custom, and anyone who wants a reference data model to argue with before writing their first migration.
Tables (36)
| Table | Columns |
|---|---|
| brands | 4 |
| cart_items | 5 |
| carts | 7 |
| categories | 5 |
| customer_addresses | 10 |
| customers | 6 |
| discount_redemptions | 6 |
| discounts | 11 |
| gift_card_transactions | 5 |
| gift_cards | 8 |
| inventory_items | 6 |
| inventory_movements | 7 |
| order_addresses | 11 |
| order_lines | 11 |
| orders | 12 |
| payment_methods | 8 |
| payments | 8 |
| product_categories | 2 |
| product_images | 6 |
| product_option_values | 4 |
| product_options | 4 |
| product_reviews | 8 |
| product_variants | 10 |
| products | 8 |
| refunds | 8 |
| return_lines | 5 |
| returns | 7 |
| shipment_lines | 4 |
| shipments | 8 |
| shipping_rates | 9 |
| shipping_zones | 3 |
| tax_rates | 5 |
| variant_option_values | 2 |
| warehouses | 5 |
| wishlist_items | 3 |
| wishlists | 5 |
Relationships (46)
cart_items.cart_id references carts.idmany to onecart_items.variant_id references product_variants.idmany to onecarts.customer_id references customers.idmany to onecategories.parent_id references categories.idmany to onecustomer_addresses.customer_id references customers.idmany to onediscount_redemptions.customer_id references customers.idmany to onediscount_redemptions.discount_id references discounts.idmany to onediscount_redemptions.order_id references orders.idmany to onegift_card_transactions.gift_card_id references gift_cards.idmany to onegift_card_transactions.order_id references orders.idmany to onegift_cards.issued_to_customer_id references customers.idmany to oneinventory_items.variant_id references product_variants.idmany to oneinventory_items.warehouse_id references warehouses.idmany to oneinventory_movements.inventory_item_id references inventory_items.idmany to oneorder_addresses.order_id references orders.idmany to oneorder_lines.order_id references orders.idmany to oneorder_lines.variant_id references product_variants.idmany to oneorders.customer_id references customers.idmany to onepayment_methods.customer_id references customers.idmany to onepayments.order_id references orders.idmany to onepayments.payment_method_id references payment_methods.idmany to oneproduct_categories.category_id references categories.idmany to oneproduct_categories.product_id references products.idmany to oneproduct_images.product_id references products.idmany to oneproduct_images.variant_id references product_variants.idmany to oneproduct_option_values.option_id references product_options.idmany to oneproduct_options.product_id references products.idmany to oneproduct_reviews.customer_id references customers.idmany to oneproduct_reviews.product_id references products.idmany to oneproduct_variants.product_id references products.idmany to oneproducts.brand_id references brands.idmany to onerefunds.payment_id references payments.idmany to onerefunds.return_id references returns.idmany to onereturn_lines.order_line_id references order_lines.idmany to onereturn_lines.return_id references returns.idmany to onereturns.order_id references orders.idmany to oneshipment_lines.order_line_id references order_lines.idmany to oneshipment_lines.shipment_id references shipments.idmany to oneshipments.order_id references orders.idmany to oneshipments.warehouse_id references warehouses.idmany to oneshipping_rates.zone_id references shipping_zones.idmany to onevariant_option_values.option_value_id references product_option_values.idmany to onevariant_option_values.variant_id references product_variants.idmany to onewishlist_items.variant_id references product_variants.idmany to onewishlist_items.wishlist_id references wishlists.idmany to onewishlists.customer_id references customers.idmany to one
How to use this template
- Open the diagram to see the tables and how they relate.
- Copy it into your workspace. You get your own editable copy.
- Export it as PostgreSQL, MySQL, or MSSQL DDL, or as C# models.
Frequently asked questions
- What is in the E-commerce Database Schema schema?
- 36 tables and 46 relationships, across 236 columns. The table names and the full relationship list are shown on this page.
- Can I export it to PostgreSQL or MySQL?
- Yes. Every DB Planner template exports as DBML, PostgreSQL, MySQL, or MSSQL DDL, and as C# models.
- Is this template free?
- Yes. You can open it in the browser without an account, and copy it into your own workspace with a free DB Planner account.
- Can I change it after copying it?
- Yes. A copy is yours: you can rename tables, add columns, and export it. Changes the author makes later do not affect your copy.