ERP Schema
An ERP schema tying together HR, procurement, sales and accounting — employees in departments, products, purchase and sales orders, invoices, and general-ledger entries — 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
Employees belong to departments; the company buys products via purchase orders to suppliers and sells them via sales orders to customers; each order produces an invoice, and invoices post entries to accounts in the general ledger.
Schema (SQL)
CREATE TABLE departments ( id SERIAL PRIMARY KEY, name VARCHAR(120) NOT NULL ); CREATE TABLE employees ( id SERIAL PRIMARY KEY, department_id INT REFERENCES departments(id), name VARCHAR(160), email VARCHAR(255) UNIQUE, hired_on DATE ); CREATE TABLE products ( id SERIAL PRIMARY KEY, sku VARCHAR(64) UNIQUE, name VARCHAR(200), unit_cost_cents INT, unit_price_cents INT ); CREATE TABLE suppliers ( id SERIAL PRIMARY KEY, name VARCHAR(160) NOT NULL ); CREATE TABLE customers ( id SERIAL PRIMARY KEY, name VARCHAR(160) NOT NULL ); CREATE TABLE purchase_orders ( id SERIAL PRIMARY KEY, supplier_id INT NOT NULL REFERENCES suppliers(id), status VARCHAR(20), ordered_at TIMESTAMP ); CREATE TABLE sales_orders ( id SERIAL PRIMARY KEY, customer_id INT NOT NULL REFERENCES customers(id), status VARCHAR(20), ordered_at TIMESTAMP ); CREATE TABLE invoices ( id SERIAL PRIMARY KEY, sales_order_id INT REFERENCES sales_orders(id), amount_cents INT, issued_at TIMESTAMP, paid BOOLEAN ); CREATE TABLE gl_accounts ( id SERIAL PRIMARY KEY, code VARCHAR(20) UNIQUE, name VARCHAR(120), type VARCHAR(20) ); CREATE TABLE ledger_entries ( id SERIAL PRIMARY KEY, invoice_id INT REFERENCES invoices(id), account_id INT NOT NULL REFERENCES gl_accounts(id), debit_cents INT, credit_cents INT, entered_at TIMESTAMP );
Open in the editor → to export it as PNG, SVG, Mermaid or DBML.