Imagine a user being part of different groups.
A group can have different roles, and a user can be part of different groups.
He also can have different roles in different groups apart from the membership.
The association of a User, a Group and a Role can be referred to as a HyperEdge.
However, it can be easily modeled in a property graph as a node that captures this n-ary relationship, as depicted below in the U1G2R1
node.
Graph
To find out in what roles a user is for a particular groups (here Group2), the following Cypher Query can traverse this HyperEdge node and provide answers.
Query
START n=node:node_auto_index(name = "User1") MATCH n-[:hasRoleInGroup]->hyperEdge-[:hasGroup]->group, hyperEdge-[:hasRole]->role WHERE group.name = "Group2" RETURN role.name
The role of User1
:
Here, find all groups and the roles a user has, sorted by the roles names.
Query
START n=node:node_auto_index(name = "User1") MATCH n-[:hasRoleInGroup]->hyperEdge-[:hasGroup]->group, hyperEdge-[:hasRole]->role RETURN role.name, group.name ORDER BY role.name ASC
The groups and roles of User1
Copyright © 2012 Neo Technology