Book a Demo

Author Topic: Is 1...n the simplified notation of0..1 <--> 0..n  (Read 4606 times)

pstein

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Is 1...n the simplified notation of0..1 <--> 0..n
« on: May 30, 2012, 10:55:02 pm »
When creating a class diagram then sometimes the designer and authors talk about 1-n relationsships.

On other places the multiplicity is more detailed e.g.

0..1 <---->0..n

Is it the same?

Or does the "1" in an 1-n relation ALWAYS mean ONLY 1..1 and "n" always ONLY an 1...n relation? Mind the exclusion here of the "0"!

Peter



KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Is 1...n the simplified notation of0..1
« Reply #1 on: May 31, 2012, 09:51:31 am »
In my opinion, the following are all 1-to-many relationships:

Code: [Select]
[1] <---> [1..*]
[1] <---> [0..*]
[0..1] <---> [1..*]
[0..1] <---> [0..*]

The "0" in each case denotes optionality. If you don't want to clutter your model with detail on optionality, choose:

Code: [Select]
   <---> [*]
« Last Edit: May 31, 2012, 09:53:18 am by KP »
The Sparx Team
[email protected]

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Is 1...n the simplified notation of0..1
« Reply #2 on: May 31, 2012, 03:28:29 pm »
The only "optional" thing is the "0.." in [0..*]
So
Code: [Select]
[*] == [0..*]For the rest, is it as expressed.
So
Code: [Select]
[1] == [1..1] != [0..1]
Geert

PS. I don't think [0..n] is valid UML syntax.
« Last Edit: May 31, 2012, 03:52:55 pm by Geert.Bellekens »

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Is 1...n the simplified notation of0..1
« Reply #3 on: May 31, 2012, 03:43:06 pm »
Geert, I was talking about meaning not syntax. Example:

Code: [Select]
Vehicle [0..1] <---> [0..*] WheelVehicles may or may not have wheels - wheels are optional. A wheel may or may not be attached to a vehicle - the vehicle is optional.

Your comment on the syntax is correct (at least it would be if YaBB hadn't hidden your '[ * ]'  - it did the same to me  >:( ). I'll just add that [1] is also optional syntax, and can be assumed if no multiplicity is shown.
« Last Edit: May 31, 2012, 03:44:00 pm by KP »
The Sparx Team
[email protected]

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Is 1...n the simplified notation of0..1
« Reply #4 on: May 31, 2012, 03:52:19 pm »
Quote
Geert, I was talking about meaning not syntax.
I know, I wasn't trying to contradict you.
Ah, now I see why you could think that, because I also used "optional".

We were absolutely talking about two different "optional"s

Geert

PS. I'll fix the [ * ] thing

pstein

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Re: Is 1...n the simplified notation of0..1
« Reply #5 on: September 09, 2012, 04:11:16 pm »
Quote
The only "optional" thing is the "0.." in [0..*]
So
Code: [Select]
[*] == [0..*]For the rest, is it as expressed.
So
Code: [Select]
[1] == [1..1] != [0..1]Geert

Ok, thank you.
But is this somehow officially defined?

Not that I doubt on your statement, but I need a proof for other colleagues:
Where can I read/verify this?

Is there an (semi-)official,central UML 2.0 syntax reference web page?

Thank you
Peter

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Is 1...n the simplified notation of0..1
« Reply #6 on: September 10, 2012, 09:49:39 am »
Quote
Not that I doubt on your statement, but I need a proof for other colleagues:
Where can I read/verify this?

Is there an (semi-)official,central UML 2.0 syntax reference web page?

Thank you
Peter
The UML spec can be downloaded free from the OMG website at http://www.uml.org/

Have a look at section 7.3.33 MultiplicityElement. Under "Presentation Options" it says:

Quote
If the lower bound is equal to the upper bound, then an alternate notation is to use the string containing just the upper bound. For example, “1” is semantically equivalent to “1..1”.

A multiplicity with zero as the lower bound and an unspecified upper bound may use the alternative notation containing a single star “*” instead of “0..*”.
« Last Edit: September 10, 2012, 01:39:59 pm by KP »
The Sparx Team
[email protected]