Association
- Tags
- modelling
Indicates a relationships between entities or classes.
\begin{figure}
\centering
\begin{tikzpicture}
\umlclass{CurrentAccount}{
accountNumber: Integer \\
balance: Real \\
overdraftLimit: Real \\
holderForename: String \\
holderSurname: String \\
holderAddress: String
}{
getBalance(): Real \\
deposit(amount: Real) \\
withdraw(amount: Real): Boolean
};
\end{tikzpicture}
\label{fig:assoc-eg-1}
\caption{An example of a badly modelled class with attributes not dependent on the class itself.}
\end{figure}
\begin{figure}
\label{fig:assoc-eg-2}
\centering
\begin{tikzpicture}
\umlclass{CurrentAccount}{
accountNumber: Integer \\
balance: Real \\
overdraftLimit: Real \\
}{
getBalance(): Real \\
deposit(amount: Real) \\
withdraw(amount: Real): Boolean
};
\umlclass[x=9]{Holder}{
forename: String \\
surname: String
}{
getForename(): String \\
getSurname(): String \\
getAddress(): String
};
\umlsimpleclass[x=9, y=-4]{Address};
\umlassoc[attr1=account|1..*, attr2=holder|1..*]{CurrentAccount}{Holder};
\umlassoc[attr1=householder|1..*, attr2=domicile|1]{Holder}{Address};
\end{tikzpicture}
\caption{Improved version of \autoref{fig:assoc-eg-1} with propper associations and multiplicities.}
\end{figure}
Multiplicities
Indicates the kind of associations we can have.
Kind | Example | Description |
---|---|---|
Mandatory | 1 | Exactly one |
Optional | 0..1 | Zero or more |
Zero or Many | 0..* | None or some |
One or Many | 1..* | At least one |
Finitely Many | 3..5 | From \( n..m \) |
Involuted Association
Is an association between a table and itself. That is a [see page 12, recursive association].
Ternary Association
Is an association between three tables simultaneously. This is generally thought of as a [see page 13, higher order association].
Realisation
Is an association where an interface is derived into a concrete subclass.