# What is a good way to show relationship between a subgroup?

**URL:** <https://community.neo4j.com/t/what-is-a-good-way-to-show-relationship-between-a-subgroup/26910>\
**Category:** Modeling\
**Created:** [October 9, 2020, 1:01pm UTC](https://community.neo4j.com/t/what-is-a-good-way-to-show-relationship-between-a-subgroup/26910 "2020-10-09T13:01:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![amukuntha](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/amukuntha/32/4334_2.png) [@amukuntha](https://community.neo4j.com/u/amukuntha)\
**Post date:** [October 9, 2020, 1:01pm UTC](https://community.neo4j.com/t/what-is-a-good-way-to-show-relationship-between-a-subgroup/26910/1 "2020-10-09T13:01:56Z")

</div>

Hi, newbie here and seriously don't know how to title this query, so pardon me on that.

We have a product hierarchy which I want to explore in Neo4j as there are lot of intricate relations that are not brought out in RDBMS. While there is top down hierarchical flow, there are lot of relationships between various nodes at same & different level. For ex, I found something like this, where there is a subgroup that are closely related within a larger group.

![image](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/2X/6/66aa07d45a8529f3f6a01a70c93d902c4625446e.png)

My question is how to group these in a way to show relationship? As of now, there are ~10 nodes in this sub group. Do I run a relation between every 2 in the 10 nodes, so 10C2 = 45 relations? Or is there a another way to show these relationship? Running 45 relationships for 10 nodes seems a over kill.

---

<div class="post-metadata">

**Author:** ![robert.quinn](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/robert.quinn/32/4248_2.png) [@robert.quinn](https://community.neo4j.com/u/robert.quinn)\
**Post date:** [October 9, 2020, 8:06pm UTC](https://community.neo4j.com/t/what-is-a-good-way-to-show-relationship-between-a-subgroup/26910/2 "2020-10-09T20:06:23Z")

</div>

One option would be to create nodes that represent the subgroups. Then link the various nodes to that subgroup node. How appropriate this solution is depends on what the subgroups represent. If the subgroups represent an alternative category or classification this would be good.

---

<div class="post-metadata">

**Author:** ![terryfranklin82](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/terryfranklin82/32/5233_2.png) [@terryfranklin82](https://community.neo4j.com/u/terryfranklin82)\
**Post date:** [October 10, 2020, 12:50am UTC](https://community.neo4j.com/t/what-is-a-good-way-to-show-relationship-between-a-subgroup/26910/3 "2020-10-10T00:50:35Z")

</div>

The previous answer is a good suggestion, but just on this point -

> [@amukuntha](#):
>
> Running 45 relationships for 10 nodes seems a over kill.

Having many more relationships than nodes is a feature of a lot of graphs that I've seen, and doesn't indicate any kind of technical or design problem. It _can_ become a problem if you end up with _hypernodes_ that have huge numbers of relationships attached, but the numbers you mention are nowhere near that level.

---

<div class="post-metadata">

**Author:** ![nghia71](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/nghia71/32/752_2.png) [@nghia71](https://community.neo4j.com/u/nghia71)\
**Post date:** [October 10, 2020, 6:35pm UTC](https://community.neo4j.com/t/what-is-a-good-way-to-show-relationship-between-a-subgroup/26910/4 "2020-10-10T18:35:26Z")

</div>

Depending on how many are those for each group:  
1/ An intermediate node to 'own' the group is good idea, but costly in traversal or more verbose Cypher  
2/ Directly linking them would be better, but too many relationships unnecessarily (I think)  
3/ Using an indexed property or a label might help, but of course you need to keep track on that.
