feat: provide support for aggregation in ER diagram

on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
darshanr0107
2025-09-01 17:07:13 +05:30
parent 82800a2c84
commit 5a167835cc
11 changed files with 600 additions and 0 deletions

View File

@@ -209,6 +209,42 @@ erDiagram
PERSON many(0) optionally to 0+ NAMED-DRIVER : is
```
### Aggregation
Aggregation represents a "has-a" relationship where the part can exist independently of the whole. This is different from composition, where the part cannot exist without the whole. Aggregation relationships are rendered with hollow diamond markers at the endpoints.
| Value | Alias for | Description |
| :---: | :------------------: | ------------------------------ |
| <> | _aggregation_ | Basic aggregation (solid line) |
| <>.. | _aggregation-dashed_ | Dashed aggregation line |
**Examples:**
```mermaid-example
erDiagram
DEPARTMENT <> EMPLOYEE : contains
PROJECT <>.. TASK : manages
TEAM <> MEMBER : consists_of
```
```mermaid
erDiagram
DEPARTMENT <> EMPLOYEE : contains
PROJECT <>.. TASK : manages
TEAM <> MEMBER : consists_of
```
In these examples:
- `DEPARTMENT <> EMPLOYEE` shows that a department contains employees (aggregation)
- `PROJECT <>.. TASK` shows that a project manages tasks (dashed aggregation)
- `TEAM <> MEMBER` shows that a team consists of members (aggregation)
**Aggregation vs Association**
- **Aggregation** (`<>`): "Has-a" relationship where parts can exist independently
- **Association** (`||--`, `}o--`): General relationship between entities
### Attributes
Attributes can be defined for entities by specifying the entity name followed by a block containing multiple `type name` pairs, where a block is delimited by an opening `{` and a closing `}`. The attributes are rendered inside the entity boxes. For example: