Book a Demo

Author Topic: Show Cardinality in Class Diagram  (Read 14468 times)

operaman

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Show Cardinality in Class Diagram
« on: January 15, 2009, 04:04:16 am »
I've looked through all of the properties for a Class diagram and can't figure out how to make the cardinality values display in the diagram. They don't appear to display by default (this is my first diagram - so not 100% certain.)  

Where do I specify that the cardinality values for associations between classes, be displayed (in the diagram).

Cheers!
<a href="http://www.linkedin.com/in/donlarsen" ><img src="http://www.linkedin.com/img/webpromo/btn_liprofile_blue_80x15.gif" width="80" height="15" border="0" alt="View Don Larsen's prof

operaman

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Show Cardinality in Class Diagram
« Reply #1 on: January 15, 2009, 05:25:10 am »
What I have since found out...

There is Cardinality property for a Class element (on the Details tab of the Class properties dialogue). I am not sure how this is used - but it is not displayed in a class diagram (not that I can see).

There is a Multiplicity property for either end of an association element (the line between two classes) where the 'multipliity' can be specified for either end of the association. This is what is displayed in Class diagram. This is very confusing!!  Are these terms properties interchangable?  Why is there a cardinality property on a Class object? Especially when a class object may have many associations with other classes? I would like to know in what scenario, one would specify a Cardinality value on the Details page of a Class property. Any help / explanation is welcome.

Cheers!  
<a href="http://www.linkedin.com/in/donlarsen" ><img src="http://www.linkedin.com/img/webpromo/btn_liprofile_blue_80x15.gif" width="80" height="15" border="0" alt="View Don Larsen's prof

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Show Cardinality in Class Diagram
« Reply #2 on: January 15, 2009, 02:47:11 pm »
I'll have a stab at this....

Cardinality and Multiplicity share the same data definition, which is basically a set of 'codes' that set limits on numbers. That is, 0, or 0-1, or 'At least 1 and not more than 5'. The definition happens to be on a tab called Cardinality on the UML Types dialog.

This is where they differ: Cardinality, in an element properties, defines the number of instances that can exist within a set for that element.  For example, if you have an airline that owns five 'planes, the Class 'Airplane' has a Cardinality of 1-5. In a model for the airline business, there should be no more than five instances of the Class 'Airplane', though there can be fewer available for assignment (if one is up for Maintenance, perhaps).

Multiplicity in a connector properties shows how many instances of the Class at 'this' end of the connector can connect to one instance of the Class at 'the other' end of the connector. So depending on what the diagram is representing, on an Association between Class 'Airplane' and Class 'Pilot' you might set a multiplity of 1 to 2 on the Class 'Airplane' end of the Association (one 'plane can be assigned to one or two pilots at a time) and a multiplicity of 1 and only 1 at the Class 'Pilot' end of the Association (one pilot can be assigned to only one 'plane at a time).

So, three separate values of Cardinality/Multiplicity in a relationship between two Classes (and I didn't even touch on the cardinality of the pilots...!). Has that really muddied the waters, or made it easier?
Best Regards, Roy

Thelonius

  • EA User
  • **
  • Posts: 274
  • Karma: +6/-0
  • I think. Therefore I get paid.
    • View Profile
Re: Show Cardinality in Class Diagram
« Reply #3 on: January 15, 2009, 03:06:57 pm »
Quote
I'll have a stab at this....

Cardinality and Multiplicity share the same data definition, which is basically a set of 'codes' that set limits on numbers. That is, 0, or 0-1, or 'At least 1 and not more than 5'. The definition happens to be on a tab called Cardinality on the UML Types dialog.

This is where they differ: Cardinality, in an element properties, defines the number of instances that can exist within a set for that element.  For example, if you have an airline that owns five 'planes, the Class 'Airplane' has a Cardinality of 1-5. In a model for the airline business, there should be no more than five instances of the Class 'Airplane', though there can be fewer available for assignment (if one is up for Maintenance, perhaps).

Multiplicity in a connector properties shows how many instances of the Class at 'this' end of the connector can connect to one instance of the Class at 'the other' end of the connector. So depending on what the diagram is representing, on an Association between Class 'Airplane' and Class 'Pilot' you might set a multiplity of 1 to 2 on the Class 'Airplane' end of the Association (one 'plane can be assigned to one or two pilots at a time) and a multiplicity of 1 and only 1 at the Class 'Pilot' end of the Association (one pilot can be assigned to only one 'plane at a time).

So, three separate values of Cardinality/Multiplicity in a relationship between two Classes (and I didn't even touch on the cardinality of the pilots...!). Has that really muddied the waters, or made it easier?

Roy - that was such a clear, lucid, coherent explanation - I even think I (!) understood it.

Did you used to be a teacher or something?

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Show Cardinality in Class Diagram
« Reply #4 on: January 15, 2009, 03:16:08 pm »
And to get back to Operaman's original question, you can't get the cardinality to display on the diagram (AFAIK), so use the multiplicity field instead: on the Properties dialog for a Class, click "Advanced" and enter the multiplicity there. You also have to set "Show Element Property String" option on the diagram properties dialog, Elements tab.
« Last Edit: January 15, 2009, 03:18:01 pm by KP »
The Sparx Team
[email protected]

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Show Cardinality in Class Diagram
« Reply #5 on: January 15, 2009, 03:44:26 pm »
Or, you can right-click on the Class on a diagram and select the Advanced | Multiplicity menu option, thereby setting just that value quickly and easily.

EDIT - after further consultation, as far as EA is concerned you can probably ignore the term Cardinality and use the term Multiplicity of Element. That might help you more easily get to the options that display the multiplicity on the element in a diagram.

Trained as a Secondary Teacher, trained as a Primary Teacher, found out that there are good reasons for schools a) being desperate for good teachers and b) making sure it is as hard as possible for teachers who are not battle-hardened to get into the profession.
« Last Edit: January 15, 2009, 04:01:13 pm by RoyC »
Best Regards, Roy

Thelonius

  • EA User
  • **
  • Posts: 274
  • Karma: +6/-0
  • I think. Therefore I get paid.
    • View Profile
Re: Show Cardinality in Class Diagram
« Reply #6 on: January 15, 2009, 05:18:41 pm »
Quote
Or, you can right-click on the Class on a diagram and select the Advanced | Multiplicity menu option, thereby setting just that value quickly and easily.

EDIT - after further consultation, as far as EA is concerned you can probably ignore the term Cardinality and use the term Multiplicity of Element. That might help you more easily get to the options that display the multiplicity on the element in a diagram.

Trained as a Secondary Teacher, trained as a Primary Teacher, found out that there are good reasons for schools a) being desperate for good teachers and b) making sure it is as hard as possible for teachers who are not battle-hardened to get into the profession.

Their loss. Our gain.

You should be the one to write a book about EA - which has been discussed elsewhere on the forum.

operaman

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Show Cardinality in Class Diagram
« Reply #7 on: January 16, 2009, 12:11:45 am »
Thanks everyone - I think I am up to speed on this topic now. I am especially heartened to discover the 'Transform Current Package' functionality in EA.

My question arose when I was trying to do some database modeling directly in EA as opposed to using the Transform functionality (transform a Class model into a database model. I read this entire article http://www.sparxsystems.com/resources/uml_datamodel.html which at no time mentions the transform functionality - I simply assumed that the modeling had to be repeated manually in a second (db) diagram. Then I saw the links (MDA Style Transforms) in the lefthand column and 'ta-da'. Very nice. 8-)
<a href="http://www.linkedin.com/in/donlarsen" ><img src="http://www.linkedin.com/img/webpromo/btn_liprofile_blue_80x15.gif" width="80" height="15" border="0" alt="View Don Larsen's prof