Diagrams
A diagram shows your tables as boxes and the foreign keys between them as lines. One model can hold many diagrams, and a table can show on several of them.
A diagram changes only the model. Moving a table, grouping tables or adding a callout never changes the database.
The diagrams are saved with the model in its .dbs file. Saving the model to a file needs DbSchema Pro.
Create a diagram
A large schema is easier to read in small diagrams, one for each part of the application, such as orders or the product catalog.
- Choose Diagram → New Diagram, or press Ctrl+L.
- Type a Name.
- Pick a table in the list on the left and press Include >>.
- Press Ok.
The new diagram opens in its own tab above the diagram area.
The Select ... menu under the list picks tables for you: All, Tables Not in Any Diagram, and the parent or child tables of the tables already included. Diagram → New Empty Diagram creates a diagram with no tables, and Diagram → Duplicate Diagram copies the current one.
Add the related tables
Every column that takes part in a foreign key has a small arrow icon at its right. The icon lists the tables linked through that column, so you can grow a diagram one step at a time.
- Click the arrow icon at the right of a column, such as
order_idinorders. - Choose Add All, or one table, such as Add payments via payments_order_id_fkey.
The tables appear next to the table you started from. If you hold Ctrl while you click the icon, each table in the list also offers Show in Diagram for the other diagrams it is on.
You can also drag a table from the tree on the left onto the diagram.
Group tables
A group is a colored box around tables that belong together, with a name in its corner.
- Click the first table header, then Ctrl+click the other tables.
- Choose Diagram → Create Group of Tables. The Table button of the toolbar has the same item.
- Type the Group Name and press OK.
The dialog also sets the group Color, and its two lists move tables in and out of the group.
Add a callout or a shape
A callout is a note on the diagram. A shape is a rectangle, an ellipse or a rhombus with a label, which marks an area of the diagram.
- Click an empty spot of the diagram. The callout or shape appears there.
- Choose Diagram → Create Callout or Diagram → Create Shape.
- Type the text. For a shape, choose the Shape and the Color.
- Press OK.
If a table is selected when you create a callout, the callout points at that table.
Arrange the tables automatically
Auto Arrange Tables lays out every table of the diagram by its foreign keys. Use it after you load a large schema, when the tables overlap.
- Choose Diagram → Auto Arrange Tables.
- Choose Arrange Only to move the tables, or Group and Arrange to also put related tables into groups.
Edit → Undo cannot bring the old positions back. To keep them, choose Diagram → Duplicate Diagram first and arrange the copy.
Show the column data types
By default, a table on the diagram shows the column names and an icon for each data type.
Choose View → Diagram Display → Column Data Type to write the data type next to each column. The Type button of the toolbar has the same switch.
Choose the item again to hide the data types.
Change how the tables look
Right-click a table header and choose Change Color to color one table. Diagram → Diagram Properties sets a custom background for the whole diagram.
The fonts, colors and borders of every diagram come from a style sheet. See CSS Settings.
The lines between the tables can use another notation, such as Barker or IDEF1X. See Read the cardinality of a line.
Zoom in and out
- View → Zoom In: Ctrl++
- View → Zoom Out: Ctrl+-
- View → Zoom 100%: Ctrl+0
- View → Choose Zoom...: Ctrl+9 opens a zoom slider.
You can also hold Ctrl and turn the mouse wheel.
Export the diagram as an image
- Open the diagram you want to export.
- Choose File → Export As... → Diagram Image.
- Choose PNG Image, GIF Image, JPG Image or SVG Image.
- Choose where to save the file.
The image holds the whole diagram, also the parts outside the window.
To publish the diagram with the details of every table, generate the HTML5 documentation instead. It holds an interactive diagram.
Common problems
Auto Arrange moved all my tables and Undo does nothing
Auto Arrange Tables cannot be undone. The dialog says so before it starts. If you saved the model before you arranged it, close the model without saving and open the file again. You lose every change made since you last saved. Next time, duplicate the diagram first, as Arrange the tables automatically shows.
How do I add all the tables related to a table?
Click the arrow icon at the right of the column and choose Add All, as Add the related tables shows. In the New Diagram dialog, the Select ... menu picks the parent or child tables of the included tables.
How do I change the look of the tables?
Use Change Color for one table, and the style sheet for all of them. See Change how the tables look.