neosemantics icon indicating copy to clipboard operation
neosemantics copied to clipboard

cannot crate multiple relations of the same type using RDF*

Open ali1k opened this issue 4 years ago • 4 comments

I am trying the RDF* syntax to add properties to the relationships e.g.

@prefix ex: <urn:ex:> .
ex:s1 a ex:Person .
ex:s2 a ex:Person .
<<ex:s1 ex:likes ex:s2>> ex:becauseOf "x" .
<<ex:s1 ex:likes ex:s2>> ex:becauseOf "y" .

When I have the same relationship type but different properties, I would expect to get two links between the above nodes but it seems after importing this ttl* data, the relationship is overwritten by the last one. can you advise me how to resolve this issue?

ali1k avatar Oct 26 '20 07:10 ali1k

Hi, all you need to do is set the graph config to use arrays as property values to hold multivalued ones: call n10s.graphconfig.init( { handleMultival: "ARRAY"}) This will store all properties in arrays but you can be more granular and specify which are the multivalued ones using the multivalPropList parameter.

Have a look at the manual on handling multivalued properties.

Cheers,

JB.

jbarrasa avatar Oct 26 '20 12:10 jbarrasa

Thanks for the answer @jbarrasa. Using multivalve option works in combining the values as array, however, it does not create a new link (in my example I still get only one 'likes' relation). I am dealing with a sequence of relationships and would like to keep the property specific to each link (i.e. two 'likes' relationships with different context), rather than combining values. Any ideas how to deal with that?

ali1k avatar Oct 26 '20 15:10 ali1k

Well, I guess that's a limitation of RDF*, isn't it? How do you tell in your example if the two statements are to be treated as a single rel with multiple properties/values or multiple rels? Both properties apply to exactly the same triple <ex:s1 ex:likes ex:s2> i.e. the same relationship. There's still no way of uniquely identify relationships :( , even with RDF* I'm afraid.

jbarrasa avatar Oct 27 '20 19:10 jbarrasa

Yeah, I get it. I just hoped you might have some configurations in n10s (e.g. handle multivalRelationships) that if selected, would enable translation of RDF* into multiple relationships. This way LPG and RDF concepts can go hand in hand to cover their conceptual limitations. E.g. I really like the URI and namespace features of RDF which is conceptually missing in the world of LPGs! anyways, the workaround I chose at the end was a singleton property:

@prefix ex: <urn:ex:> .
ex:s1 a ex:Person .
ex:s2 a ex:Person .
<<ex:s1 ex:likes-x ex:s2>> ex:becauseOf "x" ; ex:relType "likes".
<<ex:s1 ex:likes-y ex:s2>> ex:becauseOf "y" ; ex:relType "likes".

which allows creating multiple similar links with different context. And then I use cypher to resolve it in PG:

MATCH g=(s)-[r]->(p) WHERE r.ex__relType="likes" 
MERGE (s)-[:ex__likes{ex__becauseOf: r.ex__becauseOf}]->(p)
DELETE r;

ali1k avatar Oct 28 '20 07:10 ali1k