-1

I am working on a small project and I tried to represent the following two requirements in my diagram:

  1. An album may be performed by either a singer or a band (not both). My plan to implement this requirement is to create a producer class that combine both singers and bands to guarantee that only one of them has performed that specific album.

  2. TEach album has many tracks on it that are numbered sequentially, usually up to 20. Each track of an album usually corresponds to a song. I have put an association class called track between song and album that includes trackID.

Does my representation correctly represent these two requirements? enter image description here

Christophe
  • 81,699

1 Answers1

2

There are several ways to represent EITHER regarding associations in UML class diagrams:

  • If the alternative associations are with similar in kind of "things", the specialization, is an interesting and powerful candidate: it often allow to expresses an implicit reality and can be structurally enforced.
  • If the alternative associations are with unrelated "things", the use of an {XOR} is a pragmatic approach.
  • Other possibilitites involve more advance UML features such as the use of subsetting or redefining.

Your diagram is based on specialization, since the singer and the band are a specialization of the same idea of producer. The diagram nevertheless needs some improvements:

  • Your usage of generalisation accurately expresses that a Producer is a Singer or a Band.

    • But this allows also a situation where there is no SInger no Band, but just a Producer. If you want to express that Producer itself is only an abstract concept that must be specialized, you should make it as an abstract class with its name in italic.

    • You should not repeat the properties of Producer in Singer and Band: these are inherited and do not need to be explicitly repeated. Show in the specialization only properties that are not common.

  • Your usage of composition (black diamond) is incorrect: this would mean that an Album is a part of its Producer and that if its producer disappears, so does the album. Prefer the use of a simple association, with a 1 (or a 0..1 ?) multiplicity on the Producer end, and a * multiplicity on the Album end.

  • The association class Track expresses very well the relation between a Song and the Album on which it is. By the way, the line between the association line and the association class symbol should be dotted.

Useful readings, considering your focus on database modeling:

Christophe
  • 81,699