#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
⚡ FREE · SVG & PNG

ER Diagram from SQL: See Your Database Design as a Diagram

Paste your SQL schema and get an ER diagram with keys and relationships drawn for you.

  • 🗂️ Tables and columns
  • 🔑 PK, FK and unique keys
  • 🦶 Crow's foot links

How to use the ER Diagram from SQL

  1. 1. Paste your schemaCopy the CREATE TABLE statements from your project or database tool.
  2. 2. GenerateThe tool reads columns, keys and REFERENCES and draws the diagram.
  3. 3. DownloadSave the diagram as SVG or PNG for reports and documentation.

What the tool reads from your SQL

  • Every CREATE TABLE, including IF NOT EXISTS and quoted names with backticks, double quotes or square brackets.
  • Column names and types, such as VARCHAR(100) or DECIMAL(10,2).
  • PRIMARY KEY written on the column or as a separate line, including composite keys.
  • FOREIGN KEY (...) REFERENCES table(...) lines and inline REFERENCES on a column.
  • UNIQUE columns, marked UK.

Comments (-- and /* */) and INDEX or CHECK lines are skipped. A foreign key normally means one-to-many, drawn ||--o{. If the foreign key column is also unique, it is one-to-one and drawn ||--o|.

Worked example

The sample schema has departments, employees and projects. Generate it and the tool reports 3 tables, 2 relationships and 10 columns:

  • employees.dept_id → departments: each department has zero or many employees.
  • projects.lead_emp_id → employees: each employee can lead zero or many projects.

employees.email shows as UK because it is UNIQUE, and DECIMAL(10,2) is shown as DECIMAL(10-2) because the diagram language does not allow commas in type names.

Drawing the ER diagram from real SQL is a good way to check a design. Tables with no lines may be missing a foreign key, and a many-to-many link should go through a junction table, such as enrollments(student_id, course_id) between students and courses.

Frequently asked questions

Which SQL dialects work?

Standard CREATE TABLE syntax from MySQL, PostgreSQL, SQL Server and SQLite. Unusual vendor options after the closing bracket are ignored.

Can it read ALTER TABLE ... ADD FOREIGN KEY?

Not yet. Put the foreign key inside the CREATE TABLE statement, or add a REFERENCES clause to the column.

Is my schema uploaded?

No. It is read in your browser and drawn with the open-source Mermaid library from cdnjs.

Is the ER diagram tool free?

Yes, it is free. The first diagram asks for your name and WhatsApp number once, and after that all Uncodemy tools open without asking.

More free tools

See all free tools