有可能把两个弱实体联系起来吗?

时间:2022-01-31 13:03:03

In ER diagrams, is it possible to relate two weak entities each other? If possible, how can uniquely identify records in them?

在ER图中,是否有可能将两个弱实体联系起来?如果可能的话,如何才能唯一地识别其中的记录?

1 个解决方案

#1


2  

It's certainly possible. Consider the following ER diagram in which invoices are composed of lines, and receipts are decomposed into corresponding lines which are allocated to invoice lines. Multiple receipt lines can be allocated to the same InvoiceLine. It's perhaps a bit contrived but it'll serve as an example.

这当然是可能的。考虑下面的ER图,其中发票由行组成,收据被分解成相应的行,这些行被分配给发票行。可以将多个收据行分配给相同的InvoiceLine。这可能有点做作,但它可以作为一个例子。

有可能把两个弱实体联系起来吗?

The InvoiceLine entity set is identified by (InvoiceNumber, LineNumber). Similarly, the ReceiptLine entity set is identified by (ReceiptNumber, LineNumber).

InvoiceLine实体集由(InvoiceNumber, LineNumber)标识。类似地,ReceiptLine实体集由(ReceiptNumber、LineNumber)标识。

The determinant of a relationship between any entity sets is a combination of the determinants of the entity sets in many-roles. It doesn't matter whether the entity sets are weak or regular, or whether you have two or more entity sets involved in the relationship. In the case of 1:1 (or 1:1:1, etc) relationship, any of the entity sets involved can be used as a determinant.

任何实体集合之间的关系的行列式是多个角色中的实体集合的行列式的组合。实体集是弱的还是正则的,或者关系中包含两个或多个实体集,都没有关系。在1:1(或1:1)关系的情况下,任何涉及的实体集都可以用作行列式。

In our example, ReceiptLine is the only entity set in a many-role (indicated by an N next to the Paid relationship diamond). This means the relationship is determined by the determinant of ReceiptLine, which is (ReceiptNumber, LineNumber).

在我们的示例中,ReceiptLine是在多个角色中设置的惟一实体(由付费关系菱形旁边的N表示)。这意味着这个关系由接受线的行列式决定,它是(接受数,LineNumber)。

If we translate our ER diagram to a tabular model, we get the following:

如果我们把ER图转换成表格模型,我们得到以下结果:

有可能把两个弱实体联系起来吗?

I translated it directly to help you see the correspondence between the diagrams, but in practice we could denormalize the Paid relationship relation into the ReceiptLine entity relation for a simpler physical model. That can only be done for relationships with a single determining entity set, so it's important that you understand the general approach first.

我将它直接翻译为帮助您查看图之间的对应关系,但是在实践中,我们可以将付费关系关系非规范化为一个更简单的物理模型的接收线实体关系。这只能通过一个确定实体集的关系来完成,所以首先要理解一般方法是很重要的。

有可能把两个弱实体联系起来吗?

#1


2  

It's certainly possible. Consider the following ER diagram in which invoices are composed of lines, and receipts are decomposed into corresponding lines which are allocated to invoice lines. Multiple receipt lines can be allocated to the same InvoiceLine. It's perhaps a bit contrived but it'll serve as an example.

这当然是可能的。考虑下面的ER图,其中发票由行组成,收据被分解成相应的行,这些行被分配给发票行。可以将多个收据行分配给相同的InvoiceLine。这可能有点做作,但它可以作为一个例子。

有可能把两个弱实体联系起来吗?

The InvoiceLine entity set is identified by (InvoiceNumber, LineNumber). Similarly, the ReceiptLine entity set is identified by (ReceiptNumber, LineNumber).

InvoiceLine实体集由(InvoiceNumber, LineNumber)标识。类似地,ReceiptLine实体集由(ReceiptNumber、LineNumber)标识。

The determinant of a relationship between any entity sets is a combination of the determinants of the entity sets in many-roles. It doesn't matter whether the entity sets are weak or regular, or whether you have two or more entity sets involved in the relationship. In the case of 1:1 (or 1:1:1, etc) relationship, any of the entity sets involved can be used as a determinant.

任何实体集合之间的关系的行列式是多个角色中的实体集合的行列式的组合。实体集是弱的还是正则的,或者关系中包含两个或多个实体集,都没有关系。在1:1(或1:1)关系的情况下,任何涉及的实体集都可以用作行列式。

In our example, ReceiptLine is the only entity set in a many-role (indicated by an N next to the Paid relationship diamond). This means the relationship is determined by the determinant of ReceiptLine, which is (ReceiptNumber, LineNumber).

在我们的示例中,ReceiptLine是在多个角色中设置的惟一实体(由付费关系菱形旁边的N表示)。这意味着这个关系由接受线的行列式决定,它是(接受数,LineNumber)。

If we translate our ER diagram to a tabular model, we get the following:

如果我们把ER图转换成表格模型,我们得到以下结果:

有可能把两个弱实体联系起来吗?

I translated it directly to help you see the correspondence between the diagrams, but in practice we could denormalize the Paid relationship relation into the ReceiptLine entity relation for a simpler physical model. That can only be done for relationships with a single determining entity set, so it's important that you understand the general approach first.

我将它直接翻译为帮助您查看图之间的对应关系,但是在实践中,我们可以将付费关系关系非规范化为一个更简单的物理模型的接收线实体关系。这只能通过一个确定实体集的关系来完成,所以首先要理解一般方法是很重要的。

有可能把两个弱实体联系起来吗?