CRM Schema
A realistic CRM schema — accounts and their contacts, leads converting to opportunities, a sales pipeline of deals, and logged activities — shown as an interactive ER diagram.
Open this schema in the editor → All examplesInteractive diagram
Drag to pan, scroll to zoom. Open it in the full editor to edit, rearrange and export.
About this schema
Accounts (companies) have many contacts; leads are captured and converted into opportunities tied to an account; opportunities move through pipeline stages as deals, while activities (calls, emails, meetings) are logged against contacts and opportunities.
Schema (SQL)
CREATE TABLE users ( id SERIAL PRIMARY KEY, name VARCHAR(120), email VARCHAR(255) UNIQUE ); CREATE TABLE accounts ( id SERIAL PRIMARY KEY, name VARCHAR(160) NOT NULL, industry VARCHAR(80), owner_id INT REFERENCES users(id) ); CREATE TABLE contacts ( id SERIAL PRIMARY KEY, account_id INT REFERENCES accounts(id), first_name VARCHAR(80), last_name VARCHAR(80), email VARCHAR(255), phone VARCHAR(40) ); CREATE TABLE leads ( id SERIAL PRIMARY KEY, name VARCHAR(160), email VARCHAR(255), source VARCHAR(60), status VARCHAR(30), owner_id INT REFERENCES users(id) ); CREATE TABLE opportunities ( id SERIAL PRIMARY KEY, account_id INT NOT NULL REFERENCES accounts(id), name VARCHAR(160), amount_cents INT, stage VARCHAR(40), close_date DATE, owner_id INT REFERENCES users(id) ); CREATE TABLE activities ( id SERIAL PRIMARY KEY, contact_id INT REFERENCES contacts(id), opportunity_id INT REFERENCES opportunities(id), type VARCHAR(30), notes TEXT, occurred_at TIMESTAMP );
Open in the editor → to export it as PNG, SVG, Mermaid or DBML.