mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-16 13:59:54 +02:00
doc(er): add documentation on multiple key constraints
This commit is contained in:
@@ -85,6 +85,30 @@
|
|||||||
>
|
>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
|
<pre class="mermaid">
|
||||||
|
erDiagram
|
||||||
|
CAR ||--o{ NAMED-DRIVER : allows
|
||||||
|
CAR {
|
||||||
|
string registrationNumber PK
|
||||||
|
string make
|
||||||
|
string model
|
||||||
|
string[] parts
|
||||||
|
}
|
||||||
|
PERSON ||--o{ NAMED-DRIVER : is
|
||||||
|
PERSON {
|
||||||
|
string driversLicense PK "The license #"
|
||||||
|
string(99) firstName "Only 99 characters are allowed"
|
||||||
|
string lastName
|
||||||
|
string phone UK
|
||||||
|
int age
|
||||||
|
}
|
||||||
|
NAMED-DRIVER {
|
||||||
|
string carRegistrationNumber PK,FK
|
||||||
|
string driverLicence PK,FK
|
||||||
|
}
|
||||||
|
MANUFACTURER only one to zero or more CAR : makes
|
||||||
|
</pre>
|
||||||
|
|
||||||
<script src="./mermaid.js"></script>
|
<script src="./mermaid.js"></script>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
mermaid.initialize({
|
mermaid.initialize({
|
||||||
|
@@ -200,14 +200,13 @@ The `type` and `name` values must begin with an alphabetic character and may con
|
|||||||
|
|
||||||
#### Attribute Keys and Comments
|
#### Attribute Keys and Comments
|
||||||
|
|
||||||
Attributes may also have a `key` or comment defined. Keys can be "PK", "FK" or "UK", for Primary Key, Foreign Key or Unique Key. And a `comment` is defined by double quotes at the end of an attribute. Comments themselves cannot have double-quote characters in them.
|
Attributes may also have a `key` or comment defined. Keys can be `PK`, `FK` or `UK`, for Primary Key, Foreign Key or Unique Key. To specify multiple key constraints on a single attribute, separate them with a comma (e.g., `PK,FK`).. A `comment` is defined by double quotes at the end of an attribute. Comments themselves cannot have double-quote characters in them.
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
erDiagram
|
erDiagram
|
||||||
CAR ||--o{ NAMED-DRIVER : allows
|
CAR ||--o{ NAMED-DRIVER : allows
|
||||||
CAR {
|
CAR {
|
||||||
string allowedDriver FK "The license of the allowed driver"
|
string registrationNumber PK
|
||||||
string registrationNumber UK
|
|
||||||
string make
|
string make
|
||||||
string model
|
string model
|
||||||
string[] parts
|
string[] parts
|
||||||
@@ -217,17 +216,21 @@ erDiagram
|
|||||||
string driversLicense PK "The license #"
|
string driversLicense PK "The license #"
|
||||||
string(99) firstName "Only 99 characters are allowed"
|
string(99) firstName "Only 99 characters are allowed"
|
||||||
string lastName
|
string lastName
|
||||||
|
string phone UK
|
||||||
int age
|
int age
|
||||||
}
|
}
|
||||||
MANUFACTURER only one to zero or more CAR
|
NAMED-DRIVER {
|
||||||
|
string carRegistrationNumber PK,FK
|
||||||
|
string driverLicence PK,FK
|
||||||
|
}
|
||||||
|
MANUFACTURER only one to zero or more CAR : makes
|
||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
erDiagram
|
erDiagram
|
||||||
CAR ||--o{ NAMED-DRIVER : allows
|
CAR ||--o{ NAMED-DRIVER : allows
|
||||||
CAR {
|
CAR {
|
||||||
string allowedDriver FK "The license of the allowed driver"
|
string registrationNumber PK
|
||||||
string registrationNumber UK
|
|
||||||
string make
|
string make
|
||||||
string model
|
string model
|
||||||
string[] parts
|
string[] parts
|
||||||
@@ -237,9 +240,14 @@ erDiagram
|
|||||||
string driversLicense PK "The license #"
|
string driversLicense PK "The license #"
|
||||||
string(99) firstName "Only 99 characters are allowed"
|
string(99) firstName "Only 99 characters are allowed"
|
||||||
string lastName
|
string lastName
|
||||||
|
string phone UK
|
||||||
int age
|
int age
|
||||||
}
|
}
|
||||||
MANUFACTURER only one to zero or more CAR
|
NAMED-DRIVER {
|
||||||
|
string carRegistrationNumber PK,FK
|
||||||
|
string driverLicence PK,FK
|
||||||
|
}
|
||||||
|
MANUFACTURER only one to zero or more CAR : makes
|
||||||
```
|
```
|
||||||
|
|
||||||
### Other Things
|
### Other Things
|
||||||
|
@@ -146,14 +146,13 @@ The `type` and `name` values must begin with an alphabetic character and may con
|
|||||||
|
|
||||||
#### Attribute Keys and Comments
|
#### Attribute Keys and Comments
|
||||||
|
|
||||||
Attributes may also have a `key` or comment defined. Keys can be "PK", "FK" or "UK", for Primary Key, Foreign Key or Unique Key. And a `comment` is defined by double quotes at the end of an attribute. Comments themselves cannot have double-quote characters in them.
|
Attributes may also have a `key` or comment defined. Keys can be `PK`, `FK` or `UK`, for Primary Key, Foreign Key or Unique Key. To specify multiple key constraints on a single attribute, separate them with a comma (e.g., `PK,FK`).. A `comment` is defined by double quotes at the end of an attribute. Comments themselves cannot have double-quote characters in them.
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
erDiagram
|
erDiagram
|
||||||
CAR ||--o{ NAMED-DRIVER : allows
|
CAR ||--o{ NAMED-DRIVER : allows
|
||||||
CAR {
|
CAR {
|
||||||
string allowedDriver FK "The license of the allowed driver"
|
string registrationNumber PK
|
||||||
string registrationNumber UK
|
|
||||||
string make
|
string make
|
||||||
string model
|
string model
|
||||||
string[] parts
|
string[] parts
|
||||||
@@ -163,9 +162,14 @@ erDiagram
|
|||||||
string driversLicense PK "The license #"
|
string driversLicense PK "The license #"
|
||||||
string(99) firstName "Only 99 characters are allowed"
|
string(99) firstName "Only 99 characters are allowed"
|
||||||
string lastName
|
string lastName
|
||||||
|
string phone UK
|
||||||
int age
|
int age
|
||||||
}
|
}
|
||||||
MANUFACTURER only one to zero or more CAR
|
NAMED-DRIVER {
|
||||||
|
string carRegistrationNumber PK,FK
|
||||||
|
string driverLicence PK,FK
|
||||||
|
}
|
||||||
|
MANUFACTURER only one to zero or more CAR : makes
|
||||||
```
|
```
|
||||||
|
|
||||||
### Other Things
|
### Other Things
|
||||||
|
Reference in New Issue
Block a user