Question

I have a Client object which will either have a Person object or Organization object in it. These Person objects or Organization objects might have relations to other objects independent of the Client object. In this case should I use a General Aggregation association between Client -> Person and Client -> Organization where the Client object is the whole.

Also note these scenarios:

  1. Person might be a normal Person in some scenarios like; Person makes payment on behalf of Client(*Organization*)
  2. Person might be a Client which bought a Product from Us.
  3. Person might be a Supplier
Was it helpful?

Solution

While you really didn't provide enough information, it sounds like you're describing a typical Role Class Model.

I suspect that your Client doesn't really have a Person or an Organization, but rather that Person or an Organization is a Client, or IOW, either a Person or an Organization can play a role of a Client in a certain relationship.

There are various ways to model this, and no single correct solution. You might find this article helpful

OTHER TIPS

don´t forget an xor constraint between both associations (since a client cannot be connected to both a person and a organization)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top