FlowDiagram
Database & ER modelsSQL DDL

Orders schema from CREATE TABLE template

Paste DDL you already have — keys and crow’s feet come across. This data model has 7 tables and 33 columns, joined by 7 relationships. FlowDiagram draws it as an entity-relationship diagram with crow's-foot notation.

Open in the editor →
  • Free — no account, no trial, no watermark
  • Fully editable shapes and connectors, not a screenshot
  • Export PNG, SVG or PDF, or share it as a link
  • Private: the diagram never leaves your browser

Tables in this data model

  • customers — 5 columns
  • addresses — 5 columns
  • categories — 2 columns
  • products — 5 columns
  • orders — 6 columns
  • order_items — 5 columns
  • payments — 5 columns

How to use this ER diagram template

  1. Click Open in the editor. The ER diagram opens on a new page in FlowDiagram — nothing is uploaded and there is no sign-up.
  2. Rename, add or delete shapes and drag them where you want; connectors stay attached as things move.
  3. 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.
  4. Prefer text? Edit the SQL DDL below and paste it in through ☰ → Import / export SQL; the finished model exports back to DDL.
  5. 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,
  email        VARCHAR(255) NOT NULL UNIQUE,
  full_name    VARCHAR(150) NOT NULL,
  country      CHAR(2),
  signed_up_on DATE         NOT NULL
);

CREATE TABLE addresses (
  address_id  INTEGER      NOT NULL PRIMARY KEY,
  customer_id INTEGER      NOT NULL REFERENCES customers(customer_id),
  line1       VARCHAR(200) NOT NULL,
  city        VARCHAR(100) NOT NULL,
  postcode    VARCHAR(20)
);

CREATE TABLE categories (
  category_id INTEGER     NOT NULL PRIMARY KEY,
  name        VARCHAR(80) NOT NULL
);

CREATE TABLE products (
  product_id  INTEGER       NOT NULL PRIMARY KEY,
  category_id INTEGER       NOT NULL REFERENCES categories(category_id),
  sku         VARCHAR(32)   NOT NULL UNIQUE,
  name        VARCHAR(200)  NOT NULL,
  list_price  DECIMAL(10,2) NOT NULL
);

CREATE TABLE orders (
  order_id     INTEGER       NOT NULL PRIMARY KEY,
  customer_id  INTEGER       NOT NULL REFERENCES customers(customer_id),
  address_id   INTEGER       NOT NULL REFERENCES addresses(address_id),
  placed_on    DATE          NOT NULL,
  status       VARCHAR(20)   NOT NULL,
  total_amount DECIMAL(12,2) NOT NULL
);

CREATE TABLE order_items (
  order_item_id INTEGER       NOT NULL PRIMARY KEY,
  order_id      INTEGER       NOT NULL REFERENCES orders(order_id),
  product_id    INTEGER       NOT NULL REFERENCES products(product_id),
  quantity      INTEGER       NOT NULL,
  unit_price    DECIMAL(10,2) NOT NULL
);

CREATE TABLE payments (
  payment_id INTEGER       NOT NULL PRIMARY KEY,
  order_id   INTEGER       NOT NULL REFERENCES orders(order_id),
  method     VARCHAR(20)   NOT NULL,
  amount     DECIMAL(12,2) NOT NULL,
  paid_at    TIMESTAMP
);

Related: Database schema diagram tool · ER diagram from SQL · All database & er models templates · All 521 templates