Visualizers

Mermaid ER Diagram Editor

Design a database as an entity relationship diagram. Edit the example, or open the tables of our SQL Online Compiler here.

  • Runs in your browser
  • Instant results
  • Free, no sign-up
Loading the tool…

How to use the Mermaid Live Editor

  1. Write relationships like "CUSTOMER ||--o{ ORDER : places" after "erDiagram".
  2. List each table's columns in braces with their type and PK or FK.
  3. Download SVG or PNG, copy the Markdown block, or copy a share link.

Frequently asked questions

How do I read the symbols in a Mermaid ER diagram?

Each end of a line shows how many rows can match: || exactly one, |o zero or one, }o zero or more, }| one or more. "CUSTOMER ||--o{ ORDER" means one customer has zero or more orders.

How do I mark primary and foreign keys?

Add PK, FK or UK after the column, for example "int id PK" or "int customer_id FK". Several keys can be combined with commas.

Can I make an ER diagram from my SQL tables?

Yes. Run your CREATE TABLE statements in the SQL Online Compiler, open the Schema tab and choose "Open as Mermaid ER diagram". The tables, columns and foreign keys open here as an erDiagram.

What is the difference between -- and .. in an ER diagram?

A solid line (--) is an identifying relationship, where the child cannot exist without the parent. A dashed line (..) is non-identifying.

Syntax cheat sheet

CodeWhat it does
erDiagramStart an entity relationship diagram
USER ||--o{ ORDER : placesOne user places zero or more orders
|| |o }o }|Exactly one, zero or one, zero or more, one or more
-- ..Identifying (solid) and non-identifying (dashed) relationship
USER { int id PK }A table with a column, its type and a key
string email UKA unique key column
int user_id FK "owner"A foreign key column with a comment

Practice Python with coding challenges

Solve hands-on problems right in this editor: run the sample tests, submit, and get an AI code review.

All Python challenges
Easy

Rectangle Perimeter

Compute the perimeter of a rectangle from its sides.

You'll learn ArithmeticReturn values
BeginnerLearning-pathVariables
Easy

Distance Between Points

Compute the straight-line distance between two points.

You'll learn Pythagorean theoremSquare roots
BeginnerFunctionsLearning-pathmath
Easy

Average of Three

Average three whole numbers.

You'll learn ArithmeticDivision
BeginnerLearning-pathVariables
Easy

Prime Number Check

Decide whether a number is prime.

You'll learn DivisibilityLoop optimization
BeginnerLoopsNumbersStudent-beginner
Easy

Dot Product of Two Vectors

Multiply two vectors element by element and add the results: the core operation of every neuron.

You'll learn VectorsDot product
Neural networksaimachine learning
Easy

Days in a Month

Return how many days a month has, including leap years.

You'll learn Calendar rulesHelper functions
BeginnerConditionsFunctionsLearning-path
Easy

Count Uppercase Letters

Count the capital letters in a text.

You'll learn Character checksCounting
BeginnerLearning-pathStrings
Easy

Celsius to Fahrenheit

Convert a temperature from Celsius to Fahrenheit.

You'll learn FormulasOperator precedence
BeginnerLearning-pathVariables
Easy

Min and Max Together

Find the smallest and largest value in one pass.

You'll learn Single passMultiple return values
ArraysBeginnerFunctionsLearning-path
Easy

Largest of Three

Pick the largest of three numbers without a built-in max.

You'll learn ComparisonsCombining conditions
BeginnerConditionsLearning-path
Easy

Swap First and Last

Exchange the first and last items of a list.

You'll learn List indexingSwapping
ArraysBeginnerLearning-path
Easy

Password Rules Check

Check a password against simple strength rules.

You'll learn ValidationBoolean flags
BeginnerConditionsLearning-pathStrings