Search code examples
umlclass-diagram

UML Class diagram: inconsitency between 3 classes


I seem to have a problem about a simple time tracker. The way its set up is that a user can track hit time related to a project or type in something freely. This means that a timetrack object always has a user but does not always have a project. The inconsistency can occure when I create a Timetrack object in the database connected to a user, but then connect a project that does not have a association with the user to the same time track object.

Whats the best way to fix this. I've heard about directional association but I can't figure out how that solves the problem

class diagram: class diagram TimeTracker


Solution

  • I don't understand your explanation of TimeTrack, but I think that your modeling problem can only be solved by adding an integrity constraint (called "invariant" in the UML) requiring that the time track user is a member of the set of the time track project's users.

    This can be formally expressed as an OCL invariant in a constraint box attached to your TimeTrack class with the following expression:

    self.project.users->includes( self.user)