为什么有必要在ERD中指明识别或非识别关系? [英] Why is it necessary to indicate identifying or non-identifying relationships in an ERD?

查看:3234
本文介绍了为什么有必要在ERD中指明识别或非识别关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ERD中,弱/非识别关系是连接两个强实体的关系,用虚线表示。强/识别关系是将强实体连接到弱实体(弱实体是将相关实体中包含外键[FK]作为其主键[PK]的组成部分]的关系),并指示以实线。



我的问题是,那么什么?为什么分辨弱/非识别关系与强/识别关系之间的区别,ERD设计师应该分别用虚线对实线进行区分?为什么这么重要?



对于我来说,ERD中的每个元素和惯例都应该添加必要的信息,直接将数据转换为数据库设计(即DDL SQL语句),或至少解释信息重要但不一定是显而易见的(最后一例的例子就是命名关系 - 他们不会转化为SQL,但它们对理解ERD非常有用)。为了讨论起见,这是一个示例ERD(从

  • 识别和非识别关系之间的区别是什么?

  • 仍然困惑关于识别与非识别关系

  • 识别与不识别关系(再次!!!)



  • 任何人都可以向我解释附加信息,这个附加信息不包含在事实上,FK可能或可能不是PK的一部分?我正在认真考虑只是完全忽视公约(也就是说,我想用所有实线开始绘制我的ERD),但是如果有人可以指出我忽视的重要事情,我真的很感激。

    解决方案

    ER模型图中使用的惯例是,引用(外键)属性根本不会显示,除非它们是主键的一部分。如果引用属性是必需的,那么它们应该是由关系线的存在所暗示的。因此,即使它们是主键的一部分,对于外键属性也没有标准或普遍认可的ER符号。为了识别实体的实例而需要引用属性的情况通常通过使用虚线关系线在ER图上调用。这里的动机推测是主要关键属性被认为是强制性和重要性,因此它们对其他事物的依赖也是重要的。



    如果您的图表显示了外键属性那么在我看来,鉴别/不识别关系之间的区别是不重要的。无论您使用什么符号,最终重要的是您的受众都能正确地了解您的图表。


    In an ERD, a weak/non-identifying relationship is one that connects two strong entities, and is indicated with a dashed line. A strong/identifying relationship is one that connects a strong entity to a weak entity (a weak entity is one that contains the foreign key [FK] from its related entity as a component of its own primary key [PK]), and is indicated by a solid line.

    My question is, So what? Why is it so important to distinguish between weak/non-identifying relationships versus strong/identifying relationships that ERD designers are supposed to make that distinction with dashed versus solid lines, respectively? Why does it matter so much?

    For me, every element and convention in an ERD should add necessary information that either translates directly into the database design (that is, DDL SQL statements), or at least explains information that is important but not necessarily obvious (and example of this last case would be naming the relationships--they do not translate into SQL, but they are very useful for understanding the ERD). Here is a sample ERD for the sake of discussion (modified from another StackOverflow question):

    I have considered this a lot, and to me, the only information that solid versus dashed lines add is already adequately conveyed in the following conventions:

    • Whether or not an FK is part of an entity's PK (PK,FK1 or PK,FK2 in the sample ERD).
    • Whether or not the FK is a required attribute (bold) or optional attribute (not bold).

    As far as I can see, the solid versus dashed relationship line adds no additional useful information. Rather than adding information, this convention is non-intuitive and is very confusing. As just one example of the confusion they cause, there are many duplicate questions here on StackOverflow that ask which is which; here are just a few examples:

    Can anyone explain to me what additional information that convention adds that is not contained in the fact that an FK might or might not be part of a PK? I am seriously considering just ignoring the convention completely (that is, I want to start drawing my ERDs with all solid lines), but I would really appreciate it if someone could point out something important that I'm overlooking.

    解决方案

    A convention used in ER model diagrams is that referencing (foreign key) attributes are not shown at all unless they are part of a primary key. If referencing attributes are required they are supposed to be implied by the existence of a relationship line. Accordingly, there is no standard or generally agreed ER notation for foreign key attributes even when they are part of a primary key. The case where referencing attributes are needed in order to identify instances of an entity is often called out on ER diagrams by using a dotted relationship line. The motivation here is presumably that "primary" key attributes are deemed to be mandatory and significant so their dependence on other things is also significant.

    If your diagram shows foreign key attributes in some other way then the distinction between identfiying/non-identifying relationships is unimportant in my view. Whatever notation you use, ultimately what matters is that your audience understands your diagram correctly.

    这篇关于为什么有必要在ERD中指明识别或非识别关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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