-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mapping bidirectional UML relation to LinkML #146
Comments
Oy, it is big. I would need to read the detail in the New Year. I am working on a small test model that shall include all the relevant UML cases. |
@bartkl from the RDF point of view things are pretty straightforward: you need a Relation node only if you need to put some info in it (qualifiers, validity period, provenance, confidence...). There are relevant things in this repo:
|
Thanks @VladimirAlexiev, also for pointing to those ideas you wrote down. The more I think about it, the more it does indeed seem to be clear how to move forward. However, in the case of bidirectional relations - so not just two inverse slots for convenience sake, but actually a relation with no direction and two different multiplicities on both ends - you do have to state both slots are each other's inverse, no? (see the example I give above for what could go wrong otherwise). I will probably read comments here in the new year. Happy holidays and a happy new year, |
Btw, I'm writing up a beginning of this mapping in AsciiDoc. Will share as soon as something starts materializing. |
@bartkl |
Hey all,
Now that we want to create normative reference implementations and a specification of how to map UML to LinkML, I want to finally resolve some of the conundrums that have been plaguing me in my mind, and I could definitely use your help.
Problem statement
Suppose I have a bidirectional relation
R
between classesC
andD
, multiplicities on either side:How would you represent this in LinkML?
Candidate solutions
Only two potential solutions come to mind, both of which are also described in the LinkML FAQ:
Relation class
One way is to acknowledge the relation as a first-class citizen and represent it as a class that is designated to represent a relation:
Caution
I haven't tested this, and feel quite confident it won't work without some tweaking. This only emphasizes the point I'll make later on that this is just too complicated. That, or maybe I'm just dumb 😉.
Benefits
SUBJECT
,PREDICATE
andOBJECT
values forrelational_role
, and of the aggregate or composite type, etc.)Drawbacks
In conclusion: it's too complex and unreliable. Absolutely not an option in my opinion.
Two attributes
A solution that is much more natural to a tree shaped metamodel such as LinkML, is to represent the relationship as two attributes, one on each of the related classes:
Benefits
Drawbacks
Despite its drawbacks, this solution is probably the more practical one. Representing the relation as two attributes goes a long way with the CIM in particular, since - at least to my knowledge - it uses no relationship names, only role names, which makes this very smooth. Losing information about the relationship type is probably not too bad, although in the worst case it can be stored on both attributes for example.
However, the issue with the inverse statement is absolutely essential. Let me explain further, and later follow up with a possible solution.
Note
The reason why stating that both attributes are each other's inverse is essential, is because otherwise their independence could result in invalid data.
For example, suppose the following simple UML model:
We could represent this as two attributes
owns
andisOwnedBy
as follows (pseudostatements):Each <Person> <owns> exactly one <Body>
Each <Body> <isOwnedBy> exactly one <Person>
Then, suppose in some dataset we have the information:
<Bart> <owns> <1234>
<1234> <isOwnedBy> <Todd>
This is fine according to the two attributes model, but the original UML would not admit this (assuming Unique Naming Assumption). That's because the attributes should not be independent.
The issue with
inverse
and attributesSo, the inverse statements are essential, but why can't we express it? It's really only because we have used attributes to represent the relation ends, and in LinkML these cannot be referenced. This is because they are scoped to classes and are not part of the global namespace of model elements such as classes, (top-level) slots, types and enums. So there is literally no way to point to another attribute (see comment in the code above).
This brings us to the final solution candidate, where we fix this issue:
Two slots
So, what if we simply replace the attributes with slots? Let's try.
Benefits
Drawbacks
inverse
is fixed<CLASS>.
is used)Note
Although this naming convention for slots seems hard to manage, it can actually follow the exact same convention used for the URIs we map onto model elements! For example: the relation
ConductingEquipment
fromTerminal
toConductingEquipment
would then get the nameTerminal.ConductingEquipment
, and the CIM URIcim:Terminal.ConductingEquipment
, which aligns exactly!Actual CIM example of what this could look like
Conclusion
Honestly, after having typed out all of this, I don't see how any option other than the final one, i.e. the two slots solution. it is semantically correct, retains the human friendiliness and comprehensibility for both humans and generators. The only drawbacks are the lack of a single identity for the relation to put metadata on (which is hardly an issue), and the fact that what should actually be class-owned slots are now non-local, i.e. a global slot with a conventional prefix.
Anyway, I would love some input, so feel free to go ahead and tear this apart 🙂.
Related issues
The text was updated successfully, but these errors were encountered: