在一个类由另一个类组成的UML图中,是否存在隐式关联表,或者是否需要显示该表?
例如,如果我有构成段落的章节,仅此就够了:
或者像这样明确显示关联类:
我从来没有见过像后面的例子那样做,所以我假设它是隐含的。或者也许我没有正确地规范化数据(考虑到章节都出现在Chapter类和Paragraph类中)。
答案 0 :(得分:2)
简单来说,没有任何暗示。如果需要关联类,则需要对其进行定义。但是,UML并不是关于绘图,而是关于建模。如果需要,可以在图中省略关联类。不过,关联类仍将存在于您的模型中。
答案 1 :(得分:2)
No, it is not implied.
The reason why you haven't seen this is that in most cases it simply doesn't make sense. In the association class the class part additionally describes the properties of the association. In your example you create an artificial object that actually brings little or nothing. This kind of approach can be useful for many-to-many relationships which are impossible for composition (each part can have at most one whole). Even if you wanted to show Foreign Key it would simply be on one of the classes. But that's implied by the association itself. According to UML specification an inline attribute is equivalent to an association.
Moreover on UML you can depict many to many relationship simply but applying appropriate multiplicities on association ends. You may want to show the class depicting that only when modelling on the code level.
答案 2 :(得分:1)
不,不是暗指。
UML与表无关,而与类有关。类图的作者应告诉听众应如何解释类。一些UML图对真实世界进行建模,另一些对应用程序功能进行建模,而另一些则描述物理实现。
显然,在阅读您的问题时,您正在建立一个关系数据库,其中一个类是一个物理表。在那种情况下,我希望每个表都明确地建模为UML类。
UML标准对此没有要求。
顺便说一句,符号(PK)和(FK)不符合UML标准。