I'm trying to make heads or tails of a domain model. I've constructed an equivalently perplexing diagram, and my peers at work agree that this must be nonsensical. Consider the following image:
Given the default multiplicity of each end of a bi-directional association is "1", I believe this diagram is self-inconsistent. I think what the author tried to say is that there can be one dog but more than one cat, but what the image really says: there is one collar, it is associated with one cat, it is associated with one dog, and this single collar/cat/dog combination is associated with a single kennel; notice, the represented multiple association expressed in the diagram degenerates to "1-1".
It's possible that a collar (think "collar brand or model or color") might want to be shared by multiple cats or dogs, so tweaking the multiplicity between collar and cat/dog can fix this multiplicity issue, but there is still a different issue to resolve. Consider the following diagram.
Here we have "corrected" the internal inconsistency of the first domain model, but we still have a different kind of inconsistency. This model says for every kennel, there is exactly one dog, but there may be zero or more cats. To have also at least one cat, we'd want to adjust the multiplicity between the kennel and the cat like this:
But, there was a time immediately after the kennel was constructed when it had neither any cats nor a dog. Maybe this final domain model is the one which makes sense:
But even this diagram has a different issue. A cat can be reused (associated with more than one kennel), but a dog cannot? If "cat" and "dog" represent instances of cats and dogs.. like Fido and Morris, then we'd want to adjust the multiplicity of the kennel-cat association like this:
But if the "cat" and "dog" represent categories of cats and dogs.. like "Boxer" and "Tabby", then we'd want to adjust the multiplicity like this:
Do you see any incorrect assumptions when I have described the multiplicity of associations as they apply domain model diagrams? (For example, maybe the default multiplicity of an association end is "0,1" and not "1"..) If so, do you know of a website which can set me straight about the UML and how it relates to domain model diagrams?
[ December 06, 2007: Message edited by: J Jurach ] [ December 07, 2007: Message edited by: James Jurach ]
Joined: Jan 18, 2007
Hey, I thought my questions were good questions.. I'm surprised there are no takers.
Aren't one-to-one relationships transitive in a domain model?
I never saw 1 as default multiplicity... is in the spec? In my interpretation no multiplicity means unspecified (or 0..*). If you put multiplicities, probably you need to specify all of them to avoid inconsistencies like the case you show...
The first diagram should be read as: a dog is associated with one kennel and one collar a cat is associated with one collar and many kennels a collar is associated with a dog or a car a kennel is associated with a dog and many cats. Make sense and seems consistent (welll... I don't know anything about what is trying to describe)
I've no analysed your case but mine has 2 errors and I've got confirmation from sun. It's beta though
SCEA 5.0<br />SCBCD 5.0<br />SCJP 1.4
Joined: Jan 18, 2007
Originally posted by Gabriel Claramunt:
a collar is associated with a dog or a car a kennel is associated with a dog and many cats.
Why do you have OR between dog, cat with respect to collar, but then you have AND between dog, cats with respect to kennel? Unless default multiplicity really is 0..* (which is the same as * -- this would make this whole diagram meaningless), I don't see how you can justify inferring OR without more requirements. The textual overview for this whole assignment was uncomfortably sparse of any such requirements -- nowhere is collar even defined.
To express OR on a diagram like this, I believe you'd have "0,1" multiplicity on some these end points with a note which reads that at least one or the other should be present. If default multiplicity is "1", then AND must be implied.
Isn't the UML appropriately exact on points like this?
I couldn't find the specification of the default multiplicity for UML associations, but as a 1 multiplicity means the association is mandatory, and that's a very strong statement to leave unspecified. That's why I interpret all associations as optionals unless stated otherwise. On the other hand if the collar association IS mandatory, is only stating that is a special collar which needs to be attached to a dog AND a cat (a double collar?)
Although the UML standard  specifies that multi-valued attributes are allowed and that "" is the default multiplicity of attributes, some authors of popular UML books appear to be unaware of this (e.g. , p. 63). Moreover, some of the principal authors of OMT (the Object Modeling Technique from which UML class diagrams are largely derivative) argue that the default is single-valued with nullability unspecified (i.e. either  or [0..1]).
I also notice that the domain model in the Cade and Roberts book also stylistically omits directionality. When some of the same relationships are expressed in the class diagram, directionality is applied. Maybe their idea is that "1" IS in fact the correct multiplicity for at least one end of the association, but that these associations are not necessarily bi-directional.
Supposing that the directionality is stylistically omitted in the original diagram, we can fill in some of the blanks with the following diagram:
But this STILL leaves the problem of the many-to-many between Cat and Kennel. I understand the 1-1 between Dog and Kennel to mean that Dog represents an instance rather than a type: a "Marmaduke" rather than a type like "Dashound", and that "Marmaduke" can only be in only one Kennel, but does the "*" on the Kennel end of the Cat/Kennel association mean that an instance of Cat can be in more than one Kennel? Does this mean "Garfield" can be in more than one kennel at once, or does it mean that Cat possibly represents e.g. a type or breed of cat like "Siamese", but while Dog still represents an instance of a dog?
Maybe the * at the Kennel end of the Cat/Kennel association is a typo, or maybe "Cat" should have been "CatBreed" ?
Well, the Cat-Kennel relationship just means that a cat is associated with many kennels and a kennel is associated with many cats. Like a customer and bank account: one customer can have many bank accounts and a bank account can belong to more than one customer. [ December 09, 2007: Message edited by: Gabriel Claramunt ]