Database Diagram Tool - Dbdiagram.io
Creating a plan for your database schema is a good first step when starting a new project. Unfortunately, it can be a bit of a pain to use traditional diagramming tools like draw.io for this.
Dbdiagram.io is perfect, and free to use. You can even create your diagrams just by editing the text in the left-hand pane (using the published DBML format), rather than having to spend ages trying to draw things out neatly. Personally, I just want to create a clean diagram that gets the necessary information across, rather than making something that looks pretty.
Pros
- Can create diagram from just editing text.
- easy to move the table blocks around if you want to change the look.
- Can export a MySQL or PostgreSQL schema to create your database from scratch.
- Can share public link with others.
Cons
- Can't seem to use arrow keys or shift/ctrl-drag elements around to create perfectly straight lines.
- Can't seem to share with a group of people to have a single diagram that everyone can edit. If they wish to edit the diagram, they have to edit it as a new instance so hard for everyone to keep on track.
- Doesn't appear to recognize UUID as a type.
Example
Below is an example to get you started:
Table store {
id int PK
name varchar
}
Table stock {
id int PK
product_id int
store_id int
quantity int
}
Table product {
id int PK
title varchar
description text
type varchar
link varchar
image_link varchar
availability enum
price double(10,2)
}
Ref { stock.product_id > product.id }
Ref {stock.store_id > store.id }
>
, <
or -
instead of >
and it actually defines the relationship type. E.g. many-to-one, one-to-many, or one-to-one. More info.
Unique Key Combos
You can specify a compound unique key like below
Table users {
id uuid PK
first_name varchar
last_name varchar
Indexes {
(name, age) [unique]
}
}
References
First published: 21st April 2021