Ecommerce Database Schema (SQL + ERD + Prisma)

Output

SQL schema sample

CREATE TABLE users (id UUID PRIMARY KEY, email TEXT UNIQUE NOT NULL);
CREATE TABLE products (id UUID PRIMARY KEY, name TEXT NOT NULL, price_cents INT NOT NULL);
CREATE TABLE orders (id UUID PRIMARY KEY, user_id UUID REFERENCES users(id), status TEXT NOT NULL, created_at TIMESTAMPTZ DEFAULT NOW());
CREATE TABLE order_items (order_id UUID REFERENCES orders(id), product_id UUID REFERENCES products(id), quantity INT NOT NULL, PRIMARY KEY(order_id, product_id));

Diagram

users 1---* orders
orders 1---* order_items
products 1---* order_items

Use this template for checkout, catalog, and order-history flows. Add inventory, payments, and refunds as separate bounded tables.

Generate your own schema

Generate your own schema