Kickstarter
Kickstarter

Reputation: 99

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

Upvotes: 1

Views: 96

Answers (2)

qwerty_so
qwerty_so

Reputation: 36305

Instead of OCL you can also simply attach a constraint (note attached to the related connector) containing something like:

{association can only exist if there is a connection between project and user}

Upvotes: 0

Gerd Wagner
Gerd Wagner

Reputation: 5673

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)

Upvotes: 1

Related Questions