# 6. Diagrams, snapshots and comparing schemas

*Tabellum for mobile, chapter 6. On the web: https://tabellum.dudko.dev/manual/mobile/diagrams-snapshots-and-comparing-schemas*

## 6.1 Schema diagrams

The **Diagram** button next to a schema in the menu draws its tables and the foreign keys between them.

![The demo shop as a diagram](https://tabellum.dudko.dev/manual/mobile/img/diagram.jpg)

*The demo shop as a diagram*

Marked on the screenshot: (1) Find a table; (2) Columns or names only; (3) Save as SVG or PNG.

- (1) finds a table by name and centers it.
- (2) switches between full columns and table names only — the better view for a large schema.
- (3) saves the diagram as SVG, or PNG while it is small enough.

Drag the canvas to pan and pinch to zoom. Drag a table by its card to move it; Tabellum remembers where you put it. A tap on a table selects it and lights up its foreign keys, and the **Inspect** page shows it; a tap on empty canvas clears the selection.

## 6.2 Snapshots

A snapshot is a schema’s structure — tables, columns, keys, indexes, views, functions — saved as a file in `snapshots/`, without any rows. Take one with **Save schema snapshot** in the palette or the connection’s menu — before a risky change, for example — then compare against it later, or bring a database back to it.

## 6.3 Comparing two schemas

**Compare schemas** (in the palette or a connection’s menu) compares two sides: the one to migrate (1) and the one to reach (2). Each side is a connection as it is now or a saved snapshot.

![Choosing the two sides](https://tabellum.dudko.dev/manual/mobile/img/compare-dialog.jpg)

*Choosing the two sides*

Marked on the screenshot: (1) The database to migrate; (2) The state to reach.

The result lists every object as added, dropped, changed or the same, with what changed in each.

![What differs between yesterdays snapshot and the database](https://tabellum.dudko.dev/manual/mobile/img/compare.jpg)

*What differs between yesterday’s snapshot and the database*

Marked on the screenshot: (1) Also drop what the target lacks; (2) The migration as SQL.

**Migration** (2) opens the SQL that makes the left side match the right in a new tab. It runs only when you run it, through the approval dialog. Drops are left out unless **Include drops** (1) is on.
