Tables in this data model
- customers — 4 columns
- products — 4 columns
- accounts — 6 columns
- transactions — 4 columns
- postings — 5 columns
- cards — 5 columns
- loans — 4 columns
- statements — 4 columns
How to use this ER diagram template
- Click Open in the editor. The ER diagram opens on a new page in FlowDiagram — nothing is uploaded and there is no sign-up.
- Rename, add or delete shapes and drag them where you want; connectors stay attached as things move.
- Drop in vendor logos from the library — 1,160 of them, including every AWS, Azure and Google Cloud service icon — or restyle it with the colour and theme controls.
- Prefer text? Edit the SQL DDL below and paste it in through ☰ → Import / export SQL; the finished model exports back to DDL.
- Export to PNG, SVG or PDF, or press Ctrl+L for a link that carries the whole diagram.
SQL DDL source
The whole template is the text below. Paste it into FlowDiagram, keep it in Git next to the code it describes, or hand it to an AI assistant to extend.
CREATE TABLE customers (
customer_id INTEGER NOT NULL PRIMARY KEY,
full_name VARCHAR(150) NOT NULL,
kyc_status VARCHAR(20) NOT NULL,
risk_rating VARCHAR(10)
);
CREATE TABLE products (
product_id INTEGER NOT NULL PRIMARY KEY,
name VARCHAR(80) NOT NULL,
kind VARCHAR(20) NOT NULL,
interest_rate DECIMAL(6,4)
);
CREATE TABLE accounts (
account_id INTEGER NOT NULL PRIMARY KEY,
customer_id INTEGER NOT NULL REFERENCES customers(customer_id),
product_id INTEGER NOT NULL REFERENCES products(product_id),
iban VARCHAR(34) NOT NULL UNIQUE,
balance DECIMAL(18,2) NOT NULL,
status VARCHAR(20) NOT NULL
);
CREATE TABLE transactions (
txn_id INTEGER NOT NULL PRIMARY KEY,
reference VARCHAR(40) NOT NULL,
booked_at TIMESTAMP NOT NULL,
channel VARCHAR(20)
);
CREATE TABLE postings (
posting_id INTEGER NOT NULL PRIMARY KEY,
txn_id INTEGER NOT NULL REFERENCES transactions(txn_id),
account_id INTEGER NOT NULL REFERENCES accounts(account_id),
amount DECIMAL(18,2) NOT NULL,
direction CHAR(1) NOT NULL
);
CREATE TABLE cards (
card_id INTEGER NOT NULL PRIMARY KEY,
account_id INTEGER NOT NULL REFERENCES accounts(account_id),
last4 CHAR(4) NOT NULL,
status VARCHAR(20) NOT NULL,
expires_on DATE NOT NULL
);
CREATE TABLE loans (
loan_id INTEGER NOT NULL PRIMARY KEY,
account_id INTEGER NOT NULL REFERENCES accounts(account_id),
principal DECIMAL(18,2) NOT NULL,
term_months INTEGER NOT NULL
);
CREATE TABLE statements (
statement_id INTEGER NOT NULL PRIMARY KEY,
account_id INTEGER NOT NULL REFERENCES accounts(account_id),
period_start DATE NOT NULL,
period_end DATE NOT NULL
);
Related: Database schema diagram tool · ER diagram from SQL · All database & er models templates · All 521 templates