这两个实体之间是什么关系? [英] What's the relationship between the two entities?

查看:64
本文介绍了这两个实体之间是什么关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

数据库的ER图如下:

现在,飞机和航班实体之间是什么关系?

Now, what's the relationship between planes and flights entities?

我会说一对多,但那是错误的,因为一架飞机可以有多个航班,但很多航班不能同时有一架(单)飞机.

I'd say one to many, but that'd be wrong because while one plane can have more than one flights, many flights can't have one (single) plane simultaneously.

那么,究竟是什么关系?

So, what exactly is the relationship?

我是数据库的新手.如果我错了,请告诉我.

I'm new to databases. Please tell me if I'm wrong.

推荐答案

首先,您的图不是 ER 图,而是表格图.ER 图必须能够表示 ER 模型,该模型支持三元和更高的关系、弱实体集和识别关系,以及其他表格图没有符号的概念.正确的 ER 图符号通常称为陈氏符号.

First, your diagram isn't an ER diagram, it's a table diagram. ER diagrams must be able to represent the ER model, which supports ternary and higher relationships, weak entity sets and identifying relationships, and other concepts for which table diagrams don't have notation. Proper ER diagram notation is generally referred to as Chen's notation.

现在,通过查找出现在同一表中的实体域(标识实体集的列),可以轻松识别 ER 关系.这些通常用 PK 和/或 FK 表示,但它们不一定是.

Now, ER relationships are easily identified by looking for entity domains (columns that identify entity sets) that appear in the same table. These are usually indicated by PK and/or FK, but they need not be.

当您有二元关系(同一个表中有两个实体域)时,请查看对这些域的唯一约束:

When you have a binary relationship (two entity domains in the same table), look at the unique constraints on these domains:

  • 一对一关系需要两个单独的唯一约束,每个域一个.

  • One-to-one relationships require two separate unique constraints, one for each domain.

一对多关系需要在多方面对域进行唯一约束.

One-to-many relationships require a unique constraint on the domain on the many side.

多对多关系需要对两个域一起进行复合唯一约束.

Many-to-many relationships require a composite unique constraint on both domains together.

一对多关系可以非规范化为多方实体的实体关系,因为关系所需的唯一约束与实体关系的 PK 匹配.一对一关系可以非规范化为任一实体关系.多对多关系需要组合键,并且必须表示为单独的关系,因为组合键不匹配任一实体关系的 PK.

One-to-many relationships can be denormalized into the entity relation of the entity on the many side, since the unique constraint required for the relationship matches the PK for the entity relation. One-to-one relationships can be denormalized into either entity relation. A many-to-many relationship requires a composite key, and must be represented as a separate relation since the composite key doesn't match either entity relation's PK.

在您的示例中,(flight_num,planeID) 表示关系,并且由于只有 flight_num 是唯一约束的(由于是 flights 关系),这是一个多对一的关系:每个航班只与一架飞机相关联,而每架飞机都可以参与许多航班.

In your example, (flight_num, planeID) represents the relationship, and since only flight_num is uniquely constrained (due to being the PK of the flights relation), this is a many-to-one relationship: each flight is associated with exactly one plane, while each plane can be involved in many flights.

这是一个视觉参考,其中唯一的约束用下划线表示:

Here's a visual reference in which unique constraints are indicated with underlining:

许多人仍然使用旧网络数据模型中的术语和概念,例如将关系与 FK 约束和实体集与表混为一谈(这就是为什么表图经常被错误地称为 ERD).我强烈推荐阅读 Codd 的论文A Relational Model of Data for Large Shared Data Banks"和 Chen 的论文The Entity-Relationship Model - Toward a Unified View of Data".

Many people still use terminology and concepts from the old network data model, such as conflating relationships with FK constraints and entity sets with tables (which is why table diagrams are often mistakenly called ERDs). I highly recommend reading Codd's paper "A Relational Model of Data for Large Shared Data Banks" and Chen's paper "The Entity-Relationship Model - Toward a Unified View of Data".

这篇关于这两个实体之间是什么关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆