forked from JakeSteam/Mermaid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Entity Relationship Diagrams | ||
|
||
## Example | ||
|
||
```mermaid | ||
erDiagram | ||
User { | ||
Int id PK | ||
String username | ||
Int serverId FK | ||
} | ||
Server { | ||
Int id PK | ||
String serverName | ||
} | ||
Server ||--o{ User : has | ||
``` | ||
|
||
``` | ||
erDiagram | ||
User { | ||
Int id PK | ||
String username | ||
Int serverId FK | ||
} | ||
Server { | ||
Int id PK | ||
String serverName | ||
} | ||
Server ||--o{ User : has | ||
``` | ||
|
||
## Defining entities | ||
|
||
```mermaid | ||
erDiagram | ||
User { | ||
String Username PK "The user's name, a primary key" | ||
Date dateCreated "When the user was created" | ||
Int Server FK "The user's server, a foreign key" | ||
} | ||
``` | ||
|
||
``` | ||
erDiagram | ||
User { | ||
String Username PK "The user's name, a primary key" | ||
Date dateCreated "When the user was created" | ||
Int Server FK "The user's server, a foreign key" | ||
} | ||
``` | ||
|
||
## Defining relationships | ||
|
||
### Numerical relationship | ||
|
||
```mermaid | ||
erDiagram | ||
User1 |o--o| Item1 : "Zero or one - Zero or one" | ||
User2 }o--o{ Item2 : "Zero or more - Zero or more" | ||
User3 ||--|| Item3 : "Exactly one - Exactly one" | ||
User4 }|--|{ Item4 : "One or more - One or more" | ||
``` | ||
|
||
``` | ||
erDiagram | ||
User1 |o--o| Item1 : "Zero or one - Zero or one" | ||
User2 }o--o{ Item2 : "Zero or more - Zero or more" | ||
User3 ||--|| Item3 : "Exactly one - Exactly one" | ||
User4 }|--|{ Item4 : "One or more - One or more" | ||
``` | ||
|
||
### Identifying relationship | ||
|
||
```mermaid | ||
erDiagram | ||
AppleTree ||..|| Apple : "Reliant entity" | ||
Flower ||--|| Leaf : "Independent entities" | ||
``` | ||
|
||
``` | ||
erDiagram | ||
AppleTree ||..|| Apple : "Reliant entity" | ||
Flower ||--|| Leaf : "Independent entities" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters