Entity Relationship Diagrams (Chen's notation)
This page is for Chen's Entity Relationship notation, which is commonly used in teaching. See also Information Engineering diagrams. Entity Relationship (ER) diagrams are used to model databases at a conceptual level by describing entities, their attributes, and the relationships between them. In addition to basic relationships, PlantUML also supports subclasses and union types. This extended notation is sometimes referred to as Enhanced Entity Relationship (EER) or Extended Entity Relationship notation. [Ref. GH-945 and GH-1718]
最小示例
垂直(默认)
|
🎉 Copied!
|
|
横向
|
🎉 Copied!
|
|
[参考文献PR-1740]
Entities and attributes
Entities correspond to the "things" in your model. These can have attributes that describe them and those attributes can be composite (having nested attributes).
|
🎉 Copied!
|
|
Attributes can be keys, meaning that their value is unique among entities of a given type, or they can be derived, meaning that their value is computed based on other attributes. Attributes may also be multi-valued, or have their domain (set of allowed values) defined.
|
🎉 Copied!
|
|
关系
关系描述实体之间的相互关系。这些关系可以是一对一、一对多或多对多。它们可以是完全参与(强制),也可以是部分参与(可选)。全部参与用双线或粗线表示。关系也可以有属性。
|
🎉 Copied!
|
|
关系不限于两个实体。
|
🎉 Copied!
|
|
结构约束
关系的卡入度也可以用范围来表示。
|
🎉 Copied!
|
|
Identifying relationships
A weak entity does not have a key attribute that uniquely identifies each instance of that entity. Instead, it is identified by the combination of a partial key on the weak entity itself and the key of another entity, which it is related to via an identifying relationship. A weak entity must have total participation in its identifying relationship.
|
🎉 Copied!
|
|
Aliases
Entities, attributes and relationships can be given aliases to make the diagram more readable.
|
🎉 Copied!
|
|
Subclasses and categories
Entities can have subclasses and superclasses, much like in OOP, however a given subclass can have multiple superclasses. These are visually indicated using the subset symbol from set-theory.
|
🎉 Copied!
|
|
We can show how the different subclasses of a given entity are related by combining the associations. They can be either disjoint (one at a time) or overlapping (multiple at the same time).
|
🎉 Copied!
|
|
Categories or union types are similar to subclasses and can be used to group together multiple related entities.
|
🎉 Copied!
|
|
复杂示例
|
🎉 Copied!
|
|