# ERD schema

> The interactive entity-relationship diagram of your database: detail levels, schema diagnostic, new relationship and export.

Source: https://www.opendb.tools/en/docs/erd-diagram

The **ERD schema** tab draws the database's tables, their columns and their relationships.

![The entity-relationship diagram of a database](/images/docs/en/erd.webp)

## Read the diagram

Each table is a box that lists its columns. Lines link foreign keys to the columns they reference, with their **cardinality**.

OpenDB lays the tables out automatically. You can move them: your layout is kept in your workspace, and it is yours alone. **Rearrange automatically** starts over.

### Detail level

| View | What each table shows |
|---|---|
| Columns | Every column, with its type |
| Keys | Only primary and foreign keys |
| Names | Only the table name |

### Choose the tables shown

The button at the top left ("18 of 18 tables") opens the visibility filter, with a search. You can also **isolate a table with its neighbours** to focus on one part of the schema.

### View

The **View** menu sets:

- the **colors**: one per table, per name prefix, or per group of related tables;
- the **implicit relationships**: columns that look like foreign keys without having the constraint;
- the **minimap**.

## Act on a table

Click a table to open its inspector. The actions menu offers to centre it, open its data in the Tables tab, create a new SQL query or ask the chat.

The **Table** button opens the [table designer](/en/docs/table-designer) to create a new one.

## Add a relationship

The **New relationship** action adds a foreign key between two tables. OpenDB shows the statement before running it, and warns you if the referenced column is neither a primary key nor a unique index.

## Diagnostic

The **Diagnostic** button analyses the structure and lists the flaws of the schema. The number of alerts is shown on the button, and a badge marks the tables involved.

Some of the flaws detected:

- a table without a primary key;
- a column that looks like a foreign key, without a constraint;
- a foreign key whose type differs from the referenced column;
- a foreign key without an index;
- a duplicate index, or one that is a prefix of another;
- an identifier (email, slug, uuid) without a uniqueness constraint;
- an amount stored as a floating-point number;
- a boolean stored as text.

Each alert says whether it is certain or only a hint.

> [!NOTE]
> The diagnostic only reads the **structure** of the database. It never reads a row.

## Explain

The **Explain** button opens a conversation that asks the agent to explain the schema, or just the isolated table.

## Export

**Export the schema** offers four formats:

| Format | Use |
|---|---|
| DBML | For dbdiagram.io and compatible tools |
| Mermaid | For documentation written in Markdown |
| Markdown | One table per database table |
| JSON | For processing by a program |

You can also export the diagram as an image.

## Design with AI

The **Assistant** button opens a panel where you describe the tables to create or change. See [Design assistant](/en/docs/design-assistant).
