|
1 | 1 | import ThemedImage from '../src/components/ThemedImage'; |
| 2 | +import Flex from '../src/components/Flex'; |
2 | 3 |
|
3 | 4 | # Create a diagram |
4 | 5 |
|
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. |
6 | 7 |
|
| 8 | +<Flex> |
7 | 9 | <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" |
10 | 13 | /> |
| 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. |
11 | 24 |
|
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 | +/> |
13 | 30 |
|
14 | 31 | ### Define tables |
15 | 32 |
|
| 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 | + |
16 | 41 | ### Create relationships |
17 | 42 |
|
| 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 | + |
18 | 66 | ### Organize with subject areas |
19 | 67 |
|
| 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 | + |
20 | 70 | ### 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 | + |
0 commit comments