确实实体设计支持多到很多重复的关联数据的关系? [英] Does Entity Designer support many-to-many relationships with duplicate association data?

查看:139
本文介绍了确实实体设计支持多到很多重复的关联数据的关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

A套餐有一个桌面Y和一台显示器Z. B套餐有一个桌面Y和的两个的监控Z的。我要重新present由实体设计创建了一个数据库的关系。

StandardPackage 和一个多一对多的关系 StandardMachine (其中有台式机,显示器,笔记本电脑,等等)。每个季度​​,我们更新包和客户下订单。他们选择一个包,而当订单被放置,该包的 StandardMachines 抛售他们的数据(类型,品牌,型号等)到新创建

问题出在方式实体设计会为 StandardPackageStandardMachine 的关系结合表。结合表具有对应于对关系的每个端部的记录的ID两列,以及用于接合表的主键是这两个ID的组合。因此,在第一段的例子,如果程序包A的ID为1,程序包B的ID为2,桌面ÿ的ID为1,并监控Z的ID为2,我需要的是

  StandardPackageId | StandardMachineId
------------------ | ------------------
         1 | 1
         1 | 2
         2 | 1
         2 | 2
         2 | 2

但显然你不能有两个2/2的记录。

有一个很好的方式告诉实体设计什么我打算做的,所以它会创建结合表自动递增的主键列?还是我不得不求助于手动创建结表和处理协会自己?

顺便说一句,如果有人甚至知道如何重组我的问题的标题,请这样做。


解决方案

  

还是我不得不求助于手动创建结表和处理自己的关联


是的,你有。因为该表不是结合表,而是一个实体。

一个多to-many关联的语义是从要前preSS什么微妙的不同。在正n一条记录:M关联表前pressesA对于B相关的。在的的桌子它会前preSSA有B的实例。

重复时,前者的前pression永远是多余的:一个是有关B - 好吧,我们知道这一点。后者不是:A具有的B另一个实例。所以有两个<青霉>不同的实例中,这意味着每个实例具有的同一性的。身份是实体的核心理念。

所以 StandardPackageStandardMachine 只是这重新$ P $普通班psents包中的机实例,即使它仍然是一个虚拟机。

Package A has one Desktop Y and one Monitor Z. Package B has one Desktop Y and two Monitor Z's. I want to represent that relationship in a database created by Entity Designer.

There's a many-to-many relationship between StandardPackage and StandardMachine (which has desktops, monitors, laptops, etc). Every quarter, we update our packages, and clients place orders. They select a package, and when the order is placed, that package's StandardMachines dump their data (type, make, model, etc.) into newly created Machines.

The problem lies in the way Entity Designer creates the junction table for the StandardPackageStandardMachine relationship. The junction table has two columns corresponding to the IDs of the records on each end of the relationship, and the primary key for the junction table is the combination of those two IDs. So, for the example in the first paragraph, if Package A's Id is 1, Package B's Id is 2, Desktop Y's Id is 1, and Monitor Z's Id is 2, what I need is

StandardPackageId | StandardMachineId
------------------|------------------
         1        |         1        
         1        |         2
         2        |         1
         2        |         2
         2        |         2

but obviously you can't have two 2/2 records.

Is there a nice way to tell Entity Designer what I intend to do, so that it will create an auto-incrementing primary key column for the junction table? Or do I have to resort to manually creating the junction table and handling the association myself?

By the way, if someone even knows how to rephrase my question title, please do so.

解决方案

Or do I have to resort to manually creating the junction table and handling the association myself

Yes, you have. Because the table is not a junction table, but an entity.

The semantics of a many-to-many association are subtly different from what you want to express. One record in a regular n:m association table expresses "A is related to B". In your table it would express "A has an instance of B".

The former expression is always redundant when repeated: "A is related to B" - OK, we knew that. The latter isn't: "A has another instance of B". So there are two distinct instances, which means that each instance has an identity. Identity is a core concept of entities.

So StandardPackageStandardMachine is just a regular class which represents a machine instance in a package, even though it's still a 'virtual machine'.

这篇关于确实实体设计支持多到很多重复的关联数据的关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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