CRM ER diagram and database schema
The CRM database schema is a DB Planner template with 24 tables, 216 columns and 59 relationships, free to use. Core tables include account_domains, accounts, activities, activity_links. It can be opened as an interactive ER diagram or exported as PostgreSQL, MySQL, or SQL Server DDL.
- Tables
- 24
- Columns
- 216
- Relationships
- 59
- Category
- SaaS
- Exports
- DBML, SQL, C#
- Price
- Free
What this schema models
A complete CRM database design, built the way sales teams actually run a pipeline: 24 tables, 14 enums and 59 relationships covering users, teams and record ownership, campaigns and leads with a conversion record, accounts, email domains and contacts, configurable pipelines and stages, opportunities with buying committees and an append-only stage history, products, price books, line items and versioned quotes, and calls, emails, meetings, tasks and notes. THE FOUR DESIGN RULES 1. A LEAD is not a CONTACT. Leads are unqualified (form fills, badge scans, list imports) and live in their own table with a company name, not an account. Conversion writes one lead_conversions row naming the account, contact and optional opportunity the lead became, and the lead stays read-only so its source and campaign are credited with any revenue it wins. 2. Stage history is append-only, because forecasting depends on it. Every change to stage, amount, close date or forecast category writes a row carrying the full forecast state. "What did the Q3 commit look like on September 1?", stage conversion rates and slipped close dates become queries, not guesses. 3. Prices are snapshots. Products hold no price; price book entries do, per currency. Opportunity line items copy the list price and the negotiated unit price when added, and a sent quote is frozen: a change is a new version, and the old one is marked superseded. 4. Activities link to many records with real foreign keys. One meeting with two contacts about one deal at one account is one activity and four activity_links rows. Each link fills exactly one typed foreign key column, enforced by a CHECK, instead of a record_type plus record_id pair, so no link can dangle. DETAILS WORTH STEALING - Pipelines and stages are data. Each stage carries a default probability, forecast category and outcome (open, won, lost), so reports never parse stage names. - ownership_history records every reassignment, which settles commission disputes and answers "who owned this deal in Q2?" - account_domains matches incoming leads and logged emails to the right account by email domain. - Contacts carry a case-insensitive unique index on lower(email) as a duplicate guard. - Email consent is a timestamp (email_opted_out_at), not a boolean, so you can prove when it was withdrawn. - opportunity_contacts records each person's role on a deal (champion, economic buyer, blocker), because the same person plays different roles on different deals. WHAT YOU GET Clean DBML that imports directly into DB Planner, and a laid-out board with zones color-coded and framed: users and ownership, leads and campaigns, accounts and contacts, sales pipeline, products and quotes, and activities and notes. Every table carries a note. Postgres-flavoured types that port cleanly to MySQL or SQL Server. Useful for developers building a CRM or sales tool, and for students who need a realistic CRM ER diagram for a DBMS project. This is a schema design reference; territory, assignment and approval rules belong in your own business logic.
Tables (24)
| Table | Columns |
|---|---|
| account_domains | 3 |
| accounts | 13 |
| activities | 12 |
| activity_links | 6 |
| campaign_members | 7 |
| campaigns | 9 |
| contacts | 13 |
| lead_conversions | 8 |
| leads | 14 |
| notes | 10 |
| opportunities | 16 |
| opportunity_contacts | 4 |
| opportunity_line_items | 10 |
| opportunity_stage_history | 11 |
| ownership_history | 10 |
| pipeline_stages | 7 |
| pipelines | 4 |
| price_book_entries | 5 |
| price_books | 7 |
| products | 8 |
| quote_line_items | 10 |
| quotes | 15 |
| teams | 5 |
| users | 9 |
Relationships (59)
account_domains.account_id references accounts.idmany to oneaccounts.owner_id references users.idmany to oneaccounts.parent_account_id references accounts.idmany to oneactivities.owner_id references users.idmany to oneactivity_links.account_id references accounts.idmany to oneactivity_links.activity_id references activities.idmany to oneactivity_links.contact_id references contacts.idmany to oneactivity_links.lead_id references leads.idmany to oneactivity_links.opportunity_id references opportunities.idmany to onecampaign_members.campaign_id references campaigns.idmany to onecampaign_members.contact_id references contacts.idmany to onecampaign_members.lead_id references leads.idmany to onecampaigns.owner_id references users.idmany to onecontacts.account_id references accounts.idmany to onecontacts.owner_id references users.idmany to onelead_conversions.account_id references accounts.idmany to onelead_conversions.contact_id references contacts.idmany to onelead_conversions.converted_by references users.idmany to onelead_conversions.opportunity_id references opportunities.idmany to oneleads.campaign_id references campaigns.idmany to oneleads.id references lead_conversions.lead_idone to oneleads.owner_id references users.idmany to onenotes.account_id references accounts.idmany to onenotes.author_id references users.idmany to onenotes.contact_id references contacts.idmany to onenotes.lead_id references leads.idmany to onenotes.opportunity_id references opportunities.idmany to oneopportunities.account_id references accounts.idmany to oneopportunities.owner_id references users.idmany to oneopportunities.pipeline_id references pipelines.idmany to oneopportunities.price_book_id references price_books.idmany to oneopportunities.stage_id references pipeline_stages.idmany to oneopportunity_contacts.contact_id references contacts.idmany to oneopportunity_contacts.opportunity_id references opportunities.idmany to oneopportunity_line_items.opportunity_id references opportunities.idmany to oneopportunity_line_items.price_book_entry_id references price_book_entries.idmany to oneopportunity_line_items.product_id references products.idmany to oneopportunity_stage_history.changed_by references users.idmany to oneopportunity_stage_history.from_stage_id references pipeline_stages.idmany to oneopportunity_stage_history.opportunity_id references opportunities.idmany to oneopportunity_stage_history.to_stage_id references pipeline_stages.idmany to oneownership_history.account_id references accounts.idmany to oneownership_history.changed_by references users.idmany to oneownership_history.contact_id references contacts.idmany to oneownership_history.from_user_id references users.idmany to oneownership_history.lead_id references leads.idmany to oneownership_history.opportunity_id references opportunities.idmany to oneownership_history.to_user_id references users.idmany to onepipeline_stages.pipeline_id references pipelines.idmany to oneprice_book_entries.price_book_id references price_books.idmany to oneprice_book_entries.product_id references products.idmany to onequote_line_items.product_id references products.idmany to onequote_line_items.quote_id references quotes.idmany to onequotes.created_by references users.idmany to onequotes.opportunity_id references opportunities.idmany to oneteams.manager_id references users.idmany to oneteams.parent_team_id references teams.idmany to oneusers.manager_id references users.idmany to oneusers.team_id references teams.idmany to one
How to use this template
- Open the ER diagram to see the tables and how they relate.
- Copy it into your workspace. You get your own editable copy, in DBML.
- Export it as PostgreSQL, MySQL, or SQL Server DDL, or as C# models.
The copy opens in DB Planner’s ER diagram tool, with the schema as text in the DBML editor beside it. Have a database already? Turn its SQL into an ER diagram instead.
Frequently asked questions
- What is in the CRM database schema?
- 24 tables and 59 relationships, across 216 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, as PostgreSQL, MySQL, or SQL Server 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.