0..n cardinality for references?

Perhaps it's a very simple thing to do, but I'm a bit confused.

I want to define a simple model:

Group:

children: 0..n -> Person

Person:

name: string

contacts: 0..n -> Person

That is, each Person has a list of other persons.

The logical way is to define "contacts" as a reference with 0..n cardinality, not as a child.

(The structure I want to get is graph).

But references do not have 0..n cardinality.

What is the recommended approach in this case? Should I define the additional concept, like "PersonList"?

Is there a reason that children have 0..n cardinality and references do not?

Thanks

0
6 comments

Igor,

You need to create your own PersonReference concept which will contain one reference to Person concept, and add

contacts: 0..n -> PersonReference

child declaration to Person concept.

>Is there a reason that children have 0..n cardinality and references do not?

There aren't any conceptual problems here, it's just not implemented, because we had very few (or no at all) such use-cases. Maybe we will implement this later.

Regards,

Mihail

1

Thanks, I've already implemented it exactly this way.

But introducing another concept just for that doesn't feel good (from java programmer's perpective). Occam with the razor would support me :-)

0

Hi Mihail,
We are using latest MPS 2018.3.2 and i still don't see references with (0..n) being implemented. Is there any plan to do this in near future.

I am aware that for any concept A we can create a new concept called Alist and reference that in some other concept B. Now For Concept B to reference AList it has to be declared somewhere, Assume the declaration is in Concept C. when a concept C wants to declare concept A as its child with cardinality as 1 "child:A(1)" it is not possible as A should be declared via AList and if we declare "child:AList(1)" there is a possiblity of having more than one A as child.

Please let me know how to solve this issue
Regards, Anudeep

0

I'm surprised you had very few (or no at all) such use cases. I can't count how many times I have such relationships.

I would very much appreciate the [0..n] support in the children property.

By the way, it would be nice to be able to handle bidirectional relationships at the conceptual level instead of having to implement some code.

Regards, Jean-Luc

0

"I would very much appreciate the [0..n] support in the children property." - this is something MPS supports. It is the references that only support 1 and 0..1.

0

Sorry, I meant "references". I don't know why I typed "children".

0

Please sign in to leave a comment.