Qualifying the relationships with an additional property (or properties)
sounds like a sensible approach.

The simplest thing to do would be to have a boolean property to distinguish
the two types, so they would both have relationship type "KNOWS", and also
a boolean property "well".  You could use this in a cypher query like this:

start Alistair = node(1) match Alistair -[r:KNOWS]-> friend where r.well =
true return friend.name

Alternatively, as Rick suggests, if you wanted a sliding scale of knowing,
you could have a numerical property, and then do more sophisticated
traversals.  This is analogous to a weighted graph that you might use for
route planning, where each of the relationships is weighted with a property
"distance" or "time".  In cypher:

start Alistair = node(1) match Alistair -[r:KNOWS]-> friend where
r.how_well > 50 return friend.name

This property-based approach is less sophisticated than Niels' true
relationship-type-hierarchy approach, but I guess it depends on your domain
what will be most appropriate.  I think using properties is probably
simpler to implement if it meets your needs.

-Alistair

On 6 December 2011 14:14, Rick Otten <rot...@manta.com> wrote:

> Can you do this with properties on the relationship?
>
> In your example a "KNOWS" relationship could have a "how well" property,
> with values 1 to 100.
>
> You could define "KNOWS_BETTER" as  [ 50 < how well < 80 ].
> "KNOWS_BEST" as [ 80 <= how well <= 100 ].
>
> I'm not sure what the difference between a "sub relationship" and a
> "relationship qualified with properties" really is.
>
>
> -----Original Message-----
> From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org]
> On Behalf Of Sourajit Basak
> Sent: Tuesday, December 06, 2011 6:09 AM
> To: user@lists.neo4j.org
> Subject: [Neo4j] Modeling subrelationships in Neo4j
>
> Is it possible to create subrelationships in neo4j ? For e.g. a
> relationship called KNOWS_BETTER as a subrelationship of KNOWS.
>
> Do I need to explicitly connect the nodes using both relationships for the
> traversal to work ? Lets say, I create this
>
> neo4j --> KNOWS_BETTER --> graphDB, does this entails the following ?
> neo4j --> KNOWS --> graphDB.
>
> Such a scenario can be modeled in OWL Ontology, wondering if neo4j has any
> capabilities.
>
> Note: Under the hood, most OWL Ontology implementations do create these
> *extra* inferred links internally.
> _______________________________________________
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
> _______________________________________________
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>
_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to