ERD Generator

1

Define Schema

Enter table definitions

2

Generate Diagram

Create visual ERD

3

Export

Download or copy diagram

Schema Definition

Entity Relationship Diagram

Features

Generate ERD from schema
Visual entity boxes
Show relationships
Primary key highlighting
Foreign key relationships
Simple text format input
Export diagram
Multiple entities
100% client-side
No server required

What is an ERD?

An Entity Relationship Diagram (ERD) is a visual representation of database tables and their relationships. ERDs show entities (tables), attributes (columns), and relationships (foreign keys) in a clear, structured format. They're essential for database design, documentation, and communication between developers and stakeholders.

ERDs help you plan database structure before implementation, identify potential issues, and document existing databases. They show primary keys, foreign keys, data types, and cardinality (one-to-one, one-to-many, many-to-many relationships).

ERD Components

Schema Example:
User
- id: INT PRIMARY KEY
- name: VARCHAR(100)
- email: VARCHAR(100)

Post
- id: INT PRIMARY KEY
- user_id: INT FOREIGN KEY -> User.id
- title: VARCHAR(200)

Common Use Cases

1. Database Design

Plan database structure before implementation. Visualize tables, relationships, and constraints. Identify normalization opportunities and potential issues early in the design process.

2. Documentation

Document existing database schemas for team members and stakeholders. ERDs provide clear visual documentation that's easier to understand than SQL DDL statements.

3. Database Migration

Plan database migrations and schema changes. Visualize how new tables and relationships fit into existing structure. Identify affected tables and relationships.

4. Team Communication

Communicate database design to non-technical stakeholders. ERDs are more accessible than raw SQL and help everyone understand data structure.

5. Learning and Teaching

Teach database concepts and normalization. ERDs make abstract database concepts concrete and visual, helping students understand relationships and design principles.

ERD Examples

Example 1: Blog System

User
- id: INT PRIMARY KEY
- username: VARCHAR(50)
- email: VARCHAR(100)

Post
- id: INT PRIMARY KEY
- user_id: INT FOREIGN KEY -> User.id
- title: VARCHAR(200)
- content: TEXT

Comment
- id: INT PRIMARY KEY
- post_id: INT FOREIGN KEY -> Post.id
- user_id: INT FOREIGN KEY -> User.id
- content: TEXT

Example 2: E-commerce

Customer
- id: INT PRIMARY KEY
- name: VARCHAR(100)
- email: VARCHAR(100)

Order
- id: INT PRIMARY KEY
- customer_id: INT FOREIGN KEY -> Customer.id
- total: DECIMAL(10,2)
- status: VARCHAR(20)

OrderItem
- id: INT PRIMARY KEY
- order_id: INT FOREIGN KEY -> Order.id
- product_id: INT FOREIGN KEY -> Product.id
- quantity: INT
- price: DECIMAL(10,2)

Product
- id: INT PRIMARY KEY
- name: VARCHAR(200)
- price: DECIMAL(10,2)
- stock: INT

Example 3: Social Network

User
- id: INT PRIMARY KEY
- username: VARCHAR(50)
- bio: TEXT

Friendship
- id: INT PRIMARY KEY
- user_id: INT FOREIGN KEY -> User.id
- friend_id: INT FOREIGN KEY -> User.id
- status: VARCHAR(20)

Post
- id: INT PRIMARY KEY
- user_id: INT FOREIGN KEY -> User.id
- content: TEXT
- created_at: TIMESTAMP

Like
- id: INT PRIMARY KEY
- user_id: INT FOREIGN KEY -> User.id
- post_id: INT FOREIGN KEY -> Post.id

Example 4: School Management

Student
- id: INT PRIMARY KEY
- name: VARCHAR(100)
- email: VARCHAR(100)

Course
- id: INT PRIMARY KEY
- name: VARCHAR(100)
- credits: INT

Enrollment
- id: INT PRIMARY KEY
- student_id: INT FOREIGN KEY -> Student.id
- course_id: INT FOREIGN KEY -> Course.id
- grade: VARCHAR(2)

Teacher
- id: INT PRIMARY KEY
- name: VARCHAR(100)
- department: VARCHAR(50)

Example 5: Library System

Book
- id: INT PRIMARY KEY
- title: VARCHAR(200)
- isbn: VARCHAR(13)
- author: VARCHAR(100)

Member
- id: INT PRIMARY KEY
- name: VARCHAR(100)
- membership_number: VARCHAR(20)

Loan
- id: INT PRIMARY KEY
- book_id: INT FOREIGN KEY -> Book.id
- member_id: INT FOREIGN KEY -> Member.id
- loan_date: DATE
- return_date: DATE

Frequently Asked Questions

What format should I use for schema input?
Use the simple text format shown in the example. Start with entity name, then list fields with "- field_name: DATA_TYPE". Add PRIMARY KEY or FOREIGN KEY -> Entity.field for constraints.
Can I show many-to-many relationships?
Yes, create a junction table with foreign keys to both entities. For example, StudentCourse table with student_id and course_id foreign keys represents many-to-many between Student and Course.
How do I specify data types?
Use standard SQL data types: INT, VARCHAR(n), TEXT, DECIMAL(p,s), DATE, TIMESTAMP, BOOLEAN. The tool recognizes common SQL types.
Can I export the diagram?
Yes, click "Export as Text" to get a text representation. For image export, take a screenshot of the diagram. Future versions may support SVG/PNG export.
What about composite keys?
List multiple fields as PRIMARY KEY. For example: "- id, version: INT PRIMARY KEY" creates a composite key on both fields.
Can I add constraints like UNIQUE or NOT NULL?
The basic format supports PRIMARY KEY and FOREIGN KEY. For additional constraints, add them in the data type field: "email: VARCHAR(100) UNIQUE NOT NULL".
How do I show self-referencing relationships?
Use a foreign key that references the same table. For example: "parent_id: INT FOREIGN KEY -> Category.id" in a Category table creates a self-reference.
Can I import from SQL DDL?
Not directly. You'll need to convert SQL CREATE TABLE statements to the simple text format. Focus on table names, columns, and foreign key relationships.
What's the maximum number of entities?
There's no hard limit, but diagrams with more than 10-15 entities become difficult to read. Consider breaking large schemas into multiple diagrams by domain.
Can I customize the diagram appearance?
The current version uses a fixed style. You can take a screenshot and edit it in image editing software for custom colors and layouts.

Related Tools

Explore our other database and schema tools:

💙

Support TechConverter

Get $200 free DigitalOcean credit or sponsor us on GitHub!