the optionality of the relationship
having established the kind of the relationship between any two entities, you should now consider whether the relationship is optional for either or both participants. in our example, the relationship between customer and shipping method is optional in both directions—that is, customers are not required to have a default shipping method, and shipping methods can exist without being used by a customer.
当完成建立任何两实体间的关系后,你还必须确定这些关系对于参与实体的一方或双方的可选性。在我们的例子里面,客户实体和运送方式实体间的关系在两个方向都是可选的—就是说,客户并不是必须拥有一个缺省的商品运送方式,而运送方式在还没有被客户使用时依然可以独立的存在。
the relationship between product category and product, on the other hand, is only optional in one direction. a product category need not have products assigned to it, but all products must be assigned to a product category.
然而,在商品类别和商品之间的关系中,只是有一方是可选的。一种商品类别不必有一样商品归属于它中(可选的),但所有的商品都必须分门别类。
the relationship between sales order and shipping method is even more complex. a shipping method can exist independently of a sales order, so the sales order side of the relationship is optional. the shipping method side of the relationship, however, is optional only if the sales order has special instructions. this is an important constraint and should be noted on the diagram.
销售订单和运送方式之间的关系还要复杂一点。一种运送方式可以不依赖于销售订单而独立存在,所销售订单一端的关系是可选的。但在运送方式一端则只在销售订单含有特殊说明时才是可选的。这是这关系的一项重要的约束,必须在图上作出注解。 the attributes of the relationship
the attributes of the relationship
the attributes of the relationship
the attributes of the relationship
in most situations, all that you need to record about the relationship between two entities is the fact of its existence. we need to know, for example, that a specific customer placed a given sales order, and that's all we need to know. sometimes, however, we need to know additional facts about the relationship—when it began or how long it lasted, for example. these facts are attributes of the relationship itself, not of either of the participants.
在大多数的情况下,所有你要记录有关于实体间的关系的只是它的存在性。举个例子,我们需要知道某个客户下了一个销售订单,这就完了。但有时候,我们还需要知道一些“关系”额外的信息,比如关系什么时候开始,持续多长时间。这些都是关系本身的性质,而不是参与实体的性质。
where the relationship itself has attributes, it must be modeled as an entity. in the order-processing example, we might decide to designate one supplier as having "preferred supplier" status. since we already have a junction entity between product and supplier, the preferred supplier attribute can simply be added to that entity. if that were not the case, we would have needed to add an entity to represent the attributes of the relationship.
当一个“关系”本身含有属性,那么它必须被提取出来作为一个新的实体。在我们的订单过程例子里,我们可能会指定某一供应商为首选的。因为之前我们已经有一个连接实体在商品和供应商之间了,所以“首选供应商”的属性可以简单地添加到那个实体就行了。如果没有这个中间的话,我们必须创建这个实体来展现“关系”的这种属性。
additional constraints on the relationship
additional constraints on the relationship
additional constraints on the relationship
additional constraints on the relationship
finally, we want to consider whether any additional constraints pertain to the relationship. what are the minimum and maximum number of records that can exist on the many side of a one-to-many relationship? are there any conditions that must be met before the relationship is allowed to exist? are there any conditions under which the relationship must exist?
最后,我们还要考虑工“关系”是否还有其它额外的约束条件。比如说,在“一对多”关系的多的一端,实体实例最少和最多是多少,有没有限制;是否在额外的条件下“关系”才允许存在?有没有一些关系必须存在的前提条件?