Skip to content

Commit

Permalink
Adds ERM
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeSteam committed Feb 25, 2022
1 parent 3483ba0 commit e7bf992
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 0 deletions.
89 changes: 89 additions & 0 deletions 5-entity-relationship.md
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"
```
47 changes: 47 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,57 @@ classDiagram
```
<a href="/3-class.md">3: Class diagram syntax</a></td></tr>
<tr><td>

```mermaid
stateDiagram-v2
Stationary --> Moving : Begin moving
Moving --> Stationary : Stop moving
```

</td><td>

```
stateDiagram-v2
Stationary --> Moving : Begin moving
Moving --> Stationary : Stop moving
```

<a href="/4-state.md">4: State</a></td></tr>
<tr><td>

```mermaid
erDiagram
User {
Int id PK
String username
Int serverId FK
}
Server {
Int id PK
String serverName
}
Server ||--o{ User : has
```

</td><td>

```
erDiagram
User {
Int id PK
String username
Int serverId FK
}
Server {
Int id PK
String serverName
}
Server ||--o{ User : has
```
<a href="/5-entity-relationship.md">5: Entity Relationship</a></td></tr>
<tr><td>
</td><td>
Expand Down

0 comments on commit e7bf992

Please sign in to comment.