<p>The examples of associations in the previous user manual pages all showed cases where the lower-bound of the multiplicity at both ends is zero. For example there can be <a href="RoleNames.html">zero graduate students supervised by a professor, and zero professors might be assigned to supervise a graduate student initially.</a></p>

<p>Allowing a lower bound of zero means that one object can be created without having to first create the object(s) it is to be linked to. The vast majority of associations have a lower bound of zero at at least one of the two ends.</p>

<p>However there are a few situations where the lower bound at both ends of the association ought to be greater than zero. Here we will consider the one-to-one case. In the example below, a Company must always have one BoardOfDirectors and a BoardOfDirectors must always belong to one Company. But which should be created first? If we create the Company first, then a multiplicity constraint would be violated since for a period of time it would lack a Board. One solution would be to relax the constraint and decide that the association should not be 1-1. However Umple <em>does</em> allow 1-1 associations and creates a special API to allow both objects to be created at the same time.</p>

<p>The generated code has a constructor with the arguments normally found in the constructors of <em>both</em> associated classes. So in the following main program, the call to the constructor of Company with just a single argument (company name) will construct both the Company and the BoardOfDirectors and link them (the BoardOfDirectors class normally takes no argument on its constructor). If the constructor of BoardOfDirectors had had any arguments they could have been provided to the constructor of Company. The constructor of Board of Directors also could have been used to create both objects simultaneously.</p>

<p>It is worth noting that when a one-to-one association exists, there must always exist in the running system an equal number of both instances of both associated classes, and they must be linked in pairs.</p>

<p>Another observation is that modellers tend to over-use one-to-one associations. A superior modeling solution might be to merge the two classes; in this case just have a Company class.</p>

<br />

<img width="380" src="examples/OneToOneAssociations.png" title="Class diagram generated by Umple from the following example"/>

&nbsp;<br/>

@@example @@caption An Executable Example Showing the Use of a One-to-One Association @@endcaption