draw.io 绘制 ER 图

博客介绍了ER图(实体关系图),包括两种不同的ER图结构,REDs的三个组成部分:属性、关系和实体,说明了主键、外键、派生属性等概念。还分享了draw.io的使用技巧,如连接线的滑动连接和附着固定连接点,以及编辑某行的操作方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ER 图

entity relationship diagrams 实体关系图

摘自 Entity Relationship Diagrams with draw.io - draw.io

两种不同的ER 图结构

REDs的三个组成部分

1.属性

Attributes : 组成实体的各个数据。

  • In the first style of diagram, they are drawn as circles floating around their entity. In the second style, similar to UML class diagrams, they are listed within the rectangle.

  • 如果一个属性用于标识实体,则它是主键并带有下划线。如果它指的是另一个实体的标识属性,则它是外键,并用斜体表示。

  • 如果不是实际存储属性,而是根据其他属性计算属性,则该属性是派生属性,并且具有虚线轮廓。

2.关系

  • 可以用菱形表示,也可以在两个实体之间的连接器上写成文本。

  • In the first style of diagram, you can see that both User and Coach write comments, and the User can perform a habit Checkin, these two ‘actions’ aren’t represented at all in the second style of diagram, which purely represents the data, not any interactions.

  • Relationship connectors use Crow’s foot notation to show how many of each entity is related to another entity. For example, in the Habit Tracker app – A Coach can have 0 to many Users, but a User can only have 0 or 1 Coach. Users may have many Habits, and each Habit may belong to many users.

  • 将鼠标悬停在实体关系库中的每个形状上,以查看其类型。

3.实体

  • These represent a collection of data, using a rectangle with attributes ‘hanging’ off it, or box containing a list of its attributes.

  • 一个弱实体(显示为双矩形),因为它没有自己的主键——它只存在于它所属的实体中。

  • 关联实体(在第二种类型的图中更容易看到)以虚线轮廓和连接器显示——无论在哪里有多对多关系,都需要这种类型的实体。要在第一种图表样式中创建关联实体,请添加实体形状和关系形状,并将这两个形状组合在一起。

draw.io 使用技巧

连接线

  • 滑动连接:绘制关系的连接线时,请确保将鼠标悬停实例上直到轮廓变为蓝色——不要将其连接到其中一个连接点。这样,当您拖动某个实例以腾出空间时,连接线将滑动到正确的位置(自动避免交叉)。

  • 如果不希望连接线在实例周边滑动,可以将它们附着到固定连接点(小十字,悬停在形状上时以绿色突出显示)。

编辑某行

  • 选择属性行,然后按Enter键编辑该行。完成后,按CTRL+Enter退出文本编辑。使用箭头键移动到下一个实体,或按CTRL+Enter(或在MacOS上按CMD+Enter)复制该实体。

  • Inserting entities from a text file: You can insert entities directly from SQL code – click on Arrange, then Insert, then Advanced, then From Text. In the dialog, select Table from the drop down list. You’ll see example code – paste in your SQL, then click Insert.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值