Hello fellow Neo4j'ers,

for some time now I have been wondering whether it wouldn't be a nice 
feature if relationship types could be arranged in a taxonomic structure, 
i.e. like a class hierarchy. For example, in one of my use cases, I load 
terminological terms into Neo4j. The point is, that multiple terminologies 
may use the same term. Consider the following graph

Terminology1
 |__ Term1
         |__ Term2
         |__ Term3
 |__ Term4

Terminology2
|__ Term1
      |__ Term3
|__ Term5

What I mean to show is that in the example, term1 has a sub term (lets say 
in a IS-A relation) in terminology1 that it doesn't have in terminology2, 
namely term2.
To show the different terminologies in their correct structure, e.g. on a 
web site, I can do different things to sort out the issue that term1 has 
different children in the two terminologies. My currently preferred 
approach is to draw multiple edges between terms and their sub terms in the 
following way:

Term1
|_IS-A_Term2
|_IS-A-1_Term2
|_IS-A_Term3
|_IS-A-1_Term3
|_IS-A-2_Term3

This way I know that in general, term1 has the sub terms term2 and term3. 
Additionally I can tell - if I want to - that in terminology1, term2 is a 
sub term of term1 (indicated by the IS-A-1 relationship type) whereas in 
terminology2 this is not the case (expressed by the lack of a relationship 
term1-IS-A-2-term2).

In my application, I will need both information, that is, I will want to 
traverse general IS-A relationships and sometimes I will want to traverse 
relationships specific to a terminology.

I immediately thought of the following:

1) build the structure
Term1
|_IS-A-1_Term2
|_IS-A-1_Term3
|_IS-A-2_Term3

i.e. only use the terminology-specific relationship types.
2) Declare:
* relationship type IS-A-1 is a subtype of relationship type IS-A
* relationship type IS-A-2 is a subtype of relationship type IS-A

Now a cypher query like
MATCH (t:TERM)-[:IS-A]-t2 WHERE t.name='term1' RETURN t2
would return term2 and term3 whereas
MATCH (t:TERM)-[:IS-A-2]-t2 WHERE t.name='term1' RETURN t2
would only return term3.

I don't know how often people could have a use for this. Currently I solve 
this by using regular expressions on the relationship name like this:
MATCH (t:TERM)-[r]-t2 WHERE t.name='term1' AND r =~ 'IS-A.*' RETURN t2
but this construction depends on relationship naming and thus is neither 
adequate for general use nor very robust.

Perhaps this could be a valuable extension. Do you have any thoughts 
concerning this topic? Or can you actually already do this I just haven't 
seen it?

Best,

Erik

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to