Object association to itself

3
Does anyone have an example in which situations (and why) you would set an association from an object to itself?
asked
2 answers
5

If you would like to use a structure of data having several levels arranged in a treelike structure within the same object you can use an self reference.

An example can be a group which can have a subgroup, and subgroups can have subgroups, etc. In this case you can add an attribute like "ContainsSubgroups" with an enumeration with Yes/No values. Then you can determine if you are at the end of the tree or not. If a group contains one or more subgroups (self reference is filled), then the enumeration "ContainsSubgroups" is set to 'Yes', else it's set to 'No'.

Hope this will help you!

answered
-2

You can find your answer here: Relation

answered