← 所有範例
er-core
erDiagram
%% A small order book, written with every construct the ER renderer reads.
direction LR
CUSTOMER["Customer Account"] {
string id PK "the account number"
string name
string email UK,FK
}
%% A subgraph: a frame around the entities inside it. Its `direction TB` does
%% not apply: a relationship crosses its boundary (CUSTOMER ||--o{ ORDER), and
%% then Mermaid lays the block out in the document's direction, LR, instead.
%% A block's `direction` governs its members only when nothing crosses it.
subgraph fulfilment
direction TB
ORDER {
int number PK
string status
}
LINE-ITEM {
int quantity
int price
}
end
PRODUCT
WAREHOUSE
CUSTOMER ||--o{ ORDER : places
CUSTOMER |o..o| ADDRESS : "billed to"
ORDER ||--|{ LINE-ITEM : contains
LINE-ITEM }o--|| PRODUCT : names
PRODUCT }|.-|{ WAREHOUSE : stocked
PRODUCT one to zero or many LINE-ITEM : "appears in"