使用ER图

ER Diagram is a visual representation of data that describes how data is related to each other. In ER Model, we disintegrate data into entities, attributes and setup relationships between entities, all this can be represented visually using the ER diagram.

ER图是数据的直观表示,它描述了数据如何相互关联。 在ER模型中,我们将数据分解为实体,实体和实体之间的设置关系,所有这些都可以使用ER图直观地表示。

For example, in the below diagram, anyone can see and understand what the diagram wants to convey: Developer develops a website, whereas a Visitor visits a website.

例如,在下图中,任何人都可以看到并理解该图想要传达的内容: 开发人员开发一个网站,而访问者访问一个网站

example of er-diagram

ER图的组成 (Components of ER Diagram)

Entitiy, Attributes, Relationships etc form the components of ER Diagram and there are defined symbols and shapes to represent each one of them.

实体,属性,关系等构成了ER图的组成部分,并且定义了符号和形状来表示它们中的每一个。

Let's see how we can represent these in our ER Diagram.

让我们看看如何在ER图中表示它们。

实体 (Entity)

Simple rectangular box represents an Entity.

简单的矩形框代表一个实体。

Entity in ER diagram
实体之间的关系-弱和强 (Relationships between Entities - Weak and Strong)

Rhombus is used to setup relationships between two or more entities.

菱形用于建立两个或多个实体之间的关系。

Relationships in ER diagram
任何实体的属性 (Attributes for any Entity)

Ellipse is used to represent attributes of any entity. It is connected to the entity.

椭圆用于表示任何实体的属性。 它已连接到实体。

Attribute in ER diagram
弱实体 (Weak Entity)

A weak Entity is represented using double rectangular boxes. It is generally connected to another entity.

弱实体使用双矩形框表示。 它通常连接到另一个实体。

Weak Entity in ER diagram
任何实体的键属性 (Key Attribute for any Entity)

To represent a Key attribute, the attribute name inside the Ellipse is underlined.

为了表示Key属性,在椭圆内的属性名称带有下划线。

Key Attribute in ER diagram
任何实体的派生属性 (Derived Attribute for any Entity)

Derived attributes are those which are derived based on other attributes, for example, age can be derived from date of birth.

派生属性是基于其他属性派生的属性,例如,年龄可以从出生日期得出。

Derived Attribute in ER diagram
任何实体的多值属性 (Multivalued Attribute for any Entity)

Double Ellipse, one inside another, represents the attribute which can have multiple values.

双椭圆,一个在另一个内部,表示可以具有多个值的属性。

Multivalued Attribute in ER diagram
任何实体的复合属性 (Composite Attribute for any Entity)

A composite attribute is the attribute, which also has attributes.

复合属性是属性,它也具有属性。

Composite Attribute in ER diagram

ER图:实体 (ER Diagram: Entity)

An Entity can be any object, place, person or class. In ER Diagram, an entity is represented using rectangles. Consider an example of an Organisation- Employee, Manager, Department, Product and many more can be taken as entities in an Organisation.

实体可以是任何对象,地点,人或类。 在ER图中, 实体使用矩形表示。 考虑一个组织的例子-员工,经理,部门,产品,还有更多可以作为组织中的实体。

Entity example ER Diagram

The yellow rhombus in between represents a relationship.

中间的黄色菱形代表一种关系。

ER图:弱实体 (ER Diagram: Weak Entity)

Weak entity is an entity that depends on another entity. Weak entity doesn't have anay key attribute of its own. Double rectangle is used to represent a weak entity.

弱实体是依赖于另一个实体的实体。 弱实体没有自己的ayay键属性。 双矩形用于表示弱实体。

weak Entity example ER diagram

ER图:属性 (ER Diagram: Attribute)

An Attribute describes a property or characterstic of an entity. For example, Name, Age, Address etc can be attributes of a Student. An attribute is represented using eclipse.

属性描述实体的属性或特征。 例如, 姓名年龄地址等可以是Student的属性。 使用eclipse表示属性。

attribute example

ER图:关键属性 (ER Diagram: Key Attribute)

Key attribute represents the main characterstic of an Entity. It is used to represent a Primary key. Ellipse with the text underlined, represents Key Attribute.

键属性代表实体的主要特征。 它用于表示主键。 带下划线的椭圆形表示键属性。

key attribute example er diagram

ER图:复合属性 (ER Diagram: Composite Attribute)

An attribute can also have their own attributes. These attributes are known as Composite attributes.

属性也可以具有自己的属性。 这些属性称为复合属性。

composite attribute example

ER图:关系 (ER Diagram: Relationship)

A Relationship describes relation between entities. Relationship is represented using diamonds or rhombus.

关系描述实体之间的关系。 关系用菱形或菱形表示。

relationship example er diagram

There are three types of relationship that exist between Entities.

实体之间存在三种关系。

  1. Binary Relationship

    二元关系

  2. Recursive Relationship

    递归关系

  3. Ternary Relationship

    三元关系

ER图:二元关系 (ER Diagram: Binary Relationship)

Binary Relationship means relation between two Entities. This is further divided into three types.

二元关系是指两个实体之间的关系。 这进一步分为三种类型。

一对一关系 (One to One Relationship)

This type of relationship is rarely seen in real world.

这种关系在现实世界中很少见。

one-to-one relationship example er diagram

The above example describes that one student can enroll only for one course and a course will also have only one Student. This is not what you will usually see in real-world relationships.

上面的示例描述了一个学生只能注册一门课程,而一门课程也只有一名学生。 这不是您在现实世界中通常看到的关系。

一对多关系 (One to Many Relationship)

The below example showcases this relationship, which means that 1 student can opt for many courses, but a course can only have 1 student. Sounds weird! This is how it is.

下面的示例展示了这种关系,这意味着1名学生可以选择许多课程,但一门课程只能有1名学生。 听起来怪怪的! 就是这样。

one-to-many example
多对一关系 (Many to One Relationship)

It reflects business rule that many entities can be associated with just one entity. For example, Student enrolls for only one Course but a Course can have many Students.

它反映了许多实体只能与一个实体相关联的业务规则。 例如,学生仅注册一门课程,但一门课程可以有许多学生。

one-to-many example
多对多关系 (Many to Many Relationship)
many-to-many example

The above diagram represents that one student can enroll for more than one courses. And a course can have more than 1 student enrolled in it.

上图表示一个学生可以报读多门课程。 一门课程最多可以招收一名以上的学生。

ER图:递归关系 (ER Diagram: Recursive Relationship)

When an Entity is related with itself it is known as Recursive Relationship.

当实体与其自身相关时,称为递归关系。

recursive relationship example ER diagram

ER图:三元关系 (ER Diagram: Ternary Relationship)

Relationship of degree three is called Ternary relationship.

三级关系称为三元关系。

A Ternary relationship involves three entities. In such relationships we always consider two entites together and then look upon the third.

三元关系涉及三个实体。 在这样的关系中,我们总是一起考虑两个实体,然后看第三个。

ternary relationship example ER diagram

For example, in the diagram above, we have three related entities, Company, Product and Sector. To understand the relationship better or to define rules around the model, we should relate two entities and then derive the third one.

例如,在上图中,我们有三个相关实体: CompanyProductSector 。 为了更好地理解这种关系或围绕模型定义规则,我们应该关联两个实体,然后派生第三个实体。

A Company produces many Products/ each product is produced by exactly one company.

一个公司生产许多产品 /每个产品都是由一个公司生产的。

A Company operates in only one Sector / each sector has many companies operating in it.

一家公司仅在一个部门中运营/每个部门中都有许多公司在运营。

Considering the above two rules or relationships, we see that although the complete relationship involves three entities, but we are looking at two entities at a time.

考虑以上两个规则或关系,我们看到虽然完整的关系涉及三个实体,但是我们一次要查看两个实体。

翻译自: https://www.studytonight.com/dbms/er-diagram.php

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值