'Creating a viewing registry using UML
Solution 1:[1]
Is the diagram correct and is it meaningful?
The diagram seems formally correct and has the advantage of being very clear on multiplicity and role names for the DateTimeStamp.
It is diffucult to say if this approach is correct for a "registry". But it makes sense at first sight; I understand from the diagram that:
- a
Profile(user?) can do severalViewingand eachViewingis about oneAudiovisual Content. Conversely, anAudiovisual Contentcan be the subject of severalViewing, and eachViewingis performed by aProfile - Each
Viewing(of a given content by a given user) has aDateTimeStamp - Each
Audiovisual Contenthas aDateTimeStampcorresponding to the moment the content was added. - If a user views the same content several time at different moments, each of this Viewing may have a different rating, and the rating is optional.
What I can further infer from the multiplicities, is that the timestamp corresponds to the beginning of the viewing act (because if it would be the end of the viewing, there wouldn't be timestamp when the viewing starts, so the multiplicity would have been 0..1).
Areas of concern
The DateTimeStamp is a class according to your diagram. The fact that you have a 1 multiplicity on the side of the Viewing and on the side of Audiovisual Content means that every single timestamp must be associated with BOTH. I doubt that this is correct.
You could consider using 0..1 instead, which would leave the possibility of having a time stamp associated with only one of the two or none at all. But still the timestamp could possibly have both, with the risk of inconsistency between them.
Personanlly, I'd go for * to clarify that many viewing and uploading could happen at the same time. I'd probably show it as a property -addedOn: DateTimeStamp and -viewedOn:DateTimeStamp.
In reality, the time stamp is very probably a value object. You could then consider making it a «dataType»; showing it as a property may then seem even more intuitive.
Unrelated: while your current way of modeling Viewing as a class is perfectly fine, you may be interested to show is as an association class between many Profile and many Audiovisual Content
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Christophe |

