Skip to content

Commit bb6e99e

Browse files
committed
Add create diagram page
1 parent 7b43bac commit bb6e99e

28 files changed

+81
-510
lines changed

docs/create-diagram.md

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,92 @@
11
import ThemedImage from '../src/components/ThemedImage';
2+
import Flex from '../src/components/Flex';
23

34
# Create a diagram
45

5-
You can create custom diagrams for MySQL, PostgreSQL, SQLite, MariaDB, or SQL Server.
6+
To begin, go to the [online editor](https://www.drawdb.app/editor). If a previous digram gets loaded you can go to `File > New` and pick the blank diagram option.
67

8+
<Flex>
79
<ThemedImage
8-
lightImageSrc="/img/logo.png"
9-
darkImageSrc="/img/docusaurus.png"
10+
lightImageSrc={require("./img/light/file-new.png").default}
11+
darkImageSrc={require("./img/dark/file-new.png").default}
12+
alt="New File"
1013
/>
14+
<ThemedImage
15+
lightImageSrc={require("./img/light/create-blank-diagram.png").default}
16+
darkImageSrc={require("./img/dark/create-blank-diagram.png").default}
17+
alt="Create a blank diagram"
18+
/>
19+
</Flex>
20+
21+
### Pick a database
22+
23+
You can create custom or generic diagrams. Generic diagrams can be imported from or exported to any of the supported SQL flavors(MySQL, PostgreSQL, MariaDB, SQLite, MSSQL), however, they support a fewer number of types. On the other hand, custom diagrams support all the types in the given SQL flavor.
1124

12-
### Create a new blank diagram
25+
<ThemedImage
26+
lightImageSrc={require("./img/light/pick-db.png").default}
27+
darkImageSrc={require("./img/dark/pick-db.png").default}
28+
alt="Pick a database"
29+
/>
1330

1431
### Define tables
1532

33+
Add tables either from the sidebar or the toolbar and define columns.
34+
35+
<ThemedImage
36+
lightImageSrc={require("./img/light/define-tables.gif").default}
37+
darkImageSrc={require("./img/dark/define-tables.gif").default}
38+
alt="Define tables"
39+
/>
40+
1641
### Create relationships
1742

43+
To create relationships and define foreign keys start, click and hold the blue dot of the foreign key and drag and drop it on the primary column. Creating relationships follows the `start_col REFERENCES end_col` logic, so the column you start dragging from will become a foreign key.
44+
45+
46+
<ThemedImage
47+
lightImageSrc={require("./img/light/create-relationship.gif").default}
48+
darkImageSrc={require("./img/dark/create-relationship.gif").default}
49+
alt="Create a relationship"
50+
/>
51+
52+
53+
<Flex>
54+
<div>
55+
E.g. in the image above, since `posts.user_id` is the foreign key we start dragging from `user_id` to `users.id`.
56+
57+
If at some point you realize that the keys are flipped you can swap them from the `Relationships` tab. Open the relationship you'd like to edit, click on the more button next to the primary and forign columns, and then swap.
58+
</div>
59+
<ThemedImage
60+
lightImageSrc={require("./img/light/swap-keys.png").default}
61+
darkImageSrc={require("./img/dark/swap-keys.png").default}
62+
alt="Swap keys"
63+
/>
64+
</Flex>
65+
1866
### Organize with subject areas
1967

68+
You add subject areas from the `Subject Areas` tab in the sidebar or from the toolbar. They logically group the tables in subject areas to make it easier to navigate the diagram; they server a pure visual purpose and do not translate to any SQL logic and are not reflected in the generated scripts.
69+
2070
### Add notes
71+
72+
You add notes from the `Notes` tab in the sidebar or from the toolbar. You can use notes to capture any additional comments in the diagram.
73+
74+
### Custom Types
75+
76+
If the diagram type supports custom types there will be an additional `Types` tab in the sidebar. In generic diagrams the following conversions will take place when exporing to SQL.
77+
78+
79+
| **Database** | **Behavior** |
80+
|---------------------|------------------------------------------------------|
81+
| **MySQL/MariaDB** | A JSON with the corresponding JSON validation check |
82+
| **PostgreSQL** | A composite type |
83+
| **SQLite** | BLOB |
84+
| **MSSQL** | A type alias to the first field |
85+
86+
Upon adding a new type, it will be added to the list of types you can choose from when editing a column.
87+
88+
### Define Enums (PostgreSQL)
89+
90+
If the diagram is for PostgreSQL there will be an additional `Enums` tab in the sidebar where you can define enum values. Upon adding a new enum, it will be added to the list of types you can choose from when editing a column.
91+
92+
164 KB
Loading
667 KB
Loading

docs/img/dark/define-tables.gif

1.08 MB
Loading

docs/img/dark/file-new.png

155 KB
Loading

docs/img/dark/pick-db.png

100 KB
Loading

docs/img/dark/swap-keys.png

30.9 KB
Loading
160 KB
Loading
626 KB
Loading

docs/img/light/define-tables.gif

959 KB
Loading

0 commit comments

Comments
 (0)