4 tables · 1 explicit FK · 2 inferred
SQL CREATE TABLE
CREATE TABLE users ( id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, email VARCHAR(255) NOT NULL UNIQUE, name VARCHAR(100) COMMENT '用户名', PRIMARY KEY (id) ); CREATE TABLE orders ( id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, user_id BIGINT UNSIGNED NOT NULL COMMENT '下单用户', total DECIMAL(10,2) DEFAULT 0, status TINYINT(1) DEFAULT 1, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id), CONSTRAINT fk_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ); CREATE TABLE order_items ( id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, order_id BIGINT UNSIGNED NOT NULL, product_id BIGINT UNSIGNED NOT NULL, quantity INT DEFAULT 1, PRIMARY KEY (id) ); CREATE TABLE products ( id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, price DECIMAL(10,2) NOT NULL, PRIMARY KEY (id) );
Click "Render" to generate the ER diagram (first time loads Mermaid engine, ~1MB)
Mermaid code
erDiagram
    users {
        int id PK
        string email
        string name "用户名"
    }
    orders {
        int id PK
        int user_id FK "下单用户"
        number total
        int status
        datetime created_at
    }
    order_items {
        int id PK
        int order_id
        int product_id
        int quantity
    }
    products {
        int id PK
        string name
        number price
    }
    users ||--o{ orders : "cascade"
    orders ||..o{ order_items : "infers"
    products ||..o{ order_items : "infers"
User Guide
✨ Features
• Auto-detects FOREIGN KEY constraints from CREATE TABLE • Infers relations by naming convention (column user_id + table users → relation) • Outputs standard Mermaid erDiagram code — paste into GitHub / Notion / Obsidian / etc. • On-page rendering + one-click SVG / PNG export • One-click open in mermaid.live editor • All processing local; rendering engine loaded on demand
📖 How to Use
Step 1
Paste one or more CREATE TABLE statements
Step 2
Optionally turn off 'naming-convention inference' for explicit-FK only
Step 3
Click 'Render' (first click loads Mermaid, ~1MB)
Step 4
Export as SVG / PNG, or copy Mermaid code into your docs
Like it? Rate it!

Feedback List