SQL Table Relationship Viewer Online

Paste CREATE TABLE DDL and explore an interactive ER diagram with foreign keys, validation, statistics, and local exports.

Local onlyNo executionNo uploadsDDL parse only385 B input
LegendPKPrimary keyFKForeign key— —Inferred FKDeclared FKAdded (diff)Removed (diff)ΔChanged table

Visual designer

Diagram

Ready

SQL & Export

Left Panel

Right Panel

Paste SQL DDL — diagram updates automatically

How to Use

  1. Paste SQL DDL or upload a .sql file in the Monaco editor
  2. Select your SQL dialect — diagram updates automatically
  3. Pan, zoom, and click tables or relationship arrows to inspect
  4. Enable Design mode to add tables, edit columns, and connect FKs visually
  5. Set a diff baseline to highlight schema changes and export migration SQL
  6. Export Mermaid, DBML, DDL, Markdown, JSON, or PNG for documentation

Why visualize table relationships?

Production schemas grow fast. Reading hundreds of CREATE TABLE statements is slow and error-prone. An ER diagram shows parent/child links, junction tables, and missing keys at a glance — essential for migrations, onboarding, legacy analysis, and query design.

Supported databases (v1)

  • Full support: PostgreSQL, MySQL, MariaDB, SQLite, SQL Server CREATE TABLE DDL
  • Planned: Oracle, Snowflake, BigQuery, CockroachDB (partial parsing first)

Example: Users and Orders

Load the built-in sample to see a classic one-to-many relationship: orders.customer_id references users.user_id. Use this pattern to learn how foreign keys appear on the canvas and in the relationship inspector.

Related tools

Frequently Asked Questions

What is a SQL Table Relationship Viewer?

It is a tool that reads SQL DDL (CREATE TABLE scripts) and draws an Entity-Relationship Diagram (ERD) showing tables, columns, primary keys, foreign keys, and how tables connect.

What is an ER diagram?

An Entity-Relationship Diagram visualizes database tables as entities and foreign keys as relationships. It helps you understand schema structure without reading long SQL scripts.

Does this tool execute SQL?

No. It never runs SQL against a database. It only parses DDL text statically in your browser.

Is my SQL uploaded to a server?

No. Parsing and diagram generation happen locally in your browser. Your schema is not transmitted.

Which SQL dialects are supported?

PostgreSQL, MySQL, MariaDB, SQLite, and SQL Server CREATE TABLE patterns are supported in v1. Other dialects may parse partially. Select your dialect for best results.

Can I visualize SQL dump files?

Yes. Paste or upload a .sql file containing CREATE TABLE statements. INSERT and DML statements are ignored during schema extraction.

Does it detect foreign keys automatically?

Yes. Declared FOREIGN KEY constraints and inline REFERENCES clauses are parsed into relationship edges on the diagram.

Can it infer missing relationships?

Yes, optionally. Enable "Infer missing FKs" to suggest links from naming conventions like customer_id → customers. Inferred edges are shown dashed and should be reviewed.

Can I export the diagram?

Yes. Export Mermaid erDiagram, Markdown documentation, JSON schema graph, DBML, DDL, migration SQL (with baseline), matrix CSV, or PNG snapshot.

Does it support composite primary keys?

Yes. Composite PRIMARY KEY constraints and multi-column foreign keys are parsed when declared in standard DDL syntax.

Can I compare two schemas?

Yes. Set a diff baseline from your current schema, then edit SQL or use Design mode. Changed tables and relationships are highlighted on the canvas; open the Schema diff tab for details and export migration SQL.

What is the maximum supported file size?

Small and medium schemas work instantly. Inputs above ~300 KB use a Web Worker. Very large schemas above ~5 MB or ~150+ tables may slow rendering — filter or split scripts when possible.

Which browsers are supported?

Modern Chromium, Firefox, Safari, and Edge with Web Worker and localStorage support.

Does it work offline?

Yes, after the page loads. Parsing and visualization are client-side.

Is it safe for confidential schemas?

Yes. No database connection and no server upload. Processing stays on your device.

What relationship types are detected?

One-to-one, one-to-many, many-to-many (junction tables), and self-referencing relationships based on keys and table shape.

Can I inspect ON DELETE and ON UPDATE rules?

Yes. Select a relationship edge to view constraint metadata including ON DELETE / ON UPDATE when present in DDL.

Does it validate schema problems?

Yes. It reports missing primary keys, broken foreign key references, duplicate columns, isolated tables, and circular dependency warnings.

What is import order?

Import order is a suggested CREATE TABLE sequence based on foreign key dependencies — parent tables before child tables.

What is drop order?

Drop order reverses import order so child tables are removed before parent tables, respecting typical FK dependencies.

Can I search tables and columns?

Yes. Use the search box to highlight matching tables and filter the diagram view.

Does it support ALTER TABLE?

Yes. ALTER TABLE ADD CONSTRAINT FOREIGN KEY is parsed. Design mode edits regenerate CREATE TABLE DDL; use Migration SQL export (with a baseline) for ALTER-style migration scripts.

Can I design schemas visually?

Yes. Enable Design mode to add/edit/delete tables and relationships, drag table handles to connect FKs, and sync changes back to SQL DDL automatically. Undo/redo with Ctrl+Z / Ctrl+Shift+Z.

Can I drag and zoom the diagram?

Yes. The canvas supports pan, zoom, fit-to-view, and draggable table nodes with automatic layout.

How is this different from the SQL Validator?

The Validator checks SQL syntax. This tool extracts schema structure and draws relationships from valid CREATE TABLE DDL.

How is this different from dbdiagram.io or ChartDB?

This tool is integrated into DevToolsBuilder's local-first SQL suite with handoffs to validator, formatter, compare, and Learn SQL — no account required.

Can students use this to learn SQL?

Yes. Load the Users & Orders sample and cross-link to Learn SQL lessons on joins, keys, and relational modeling.

Does it use AI?

No. Parsing and layout are deterministic. No LLM calls are made.

Can I copy Mermaid for GitHub docs?

Yes. Export or copy Mermaid erDiagram syntax for README files, wikis, and Mermaid-compatible renderers.

What if parsing fails?

Ensure your script contains CREATE TABLE statements with supported syntax. Open the SQL Validator from the toolbar to fix syntax issues first.

Is this tool free?

Yes. No account, usage limit, or per-diagram charge.