Comments (11)
Hi @flyly0755! In neo4j a relationship must be connected to exactly 2 nodes. However, you can have multiple labels which makes it easy to "group" nodes. Let's say you want to create a mother and a father which are parent of a child. You could create two relationships like this:
CREATE (mother:Mother:Parent)-[:PARENT_OF]->(child:Child{name:"kalle"})
CREATE (father:Father:Parent)-[:PARENT_OF]->(child)
if you then would like to find both parents, you could do that with the query:
MATCH (parent:Parent)-[:PARENT_OF]-(:Child{name:"kalle"}) RETURN parent
So, you can't have more than two nodes per relationship - but you can use multiple labels for your nodes and pattern matching to find all relationships to a given node. Does this help you? Please let me know if I have misunderstood your question/feature request.
from neo4j.
@LinneaAndersson yes, a node can with multiple labels, which can be very useful.
relationship must be connected to exactly 2 nodes. -- This is a basic prerequisite.
What i think about is whether we can consider node-set concept, which can bring lots of convenience to indicate physical world include-relationship instead of point to point relationship, for example:
FamilyA contains fatherA, matherA, childA, and FamilyB contain fatherB, matherB, childB.
Assume FamilyA is a node with 3 sub-nodes(fatherA, matherA, childA),
FamilyB is a node with 3 sub-nodes(fatherB, matherB, childB), So family and member are include-relationship.
and FamilyA, FamilyB are good neighbor which is point to point relationship.
This is related with geometry(point, edge and so on), maybe what i think above is not feasible with geometry foundation:)
from neo4j.
@flyly0755 Ok, now I think I understand your question/feature-request π
I will add it as a feature request. The only thing I can come up with that you could do today, is that you could create a node which is the node-set (in this case it would then be to create family nodes):
Or in cypher:
CREATE (familyA:Family{name:"familyA"}),
(familyA)-[:HAS_FAMILY_MEMBER]->(childa:Child{name:"childA"}),
(familyA)-[:HAS_FAMILY_MEMBER]->(mothera:Mother{name:"motherA"}),
(familyA)-[:HAS_FAMILY_MEMBER]->(fathera:Father{name:"fatherA"}),
(fathera)-[:PARENT_TO]->(childa),
(mothera)-[:PARENT_TO]->(childa)
CREATE (familyB:Family{name:"familyB"}),
(familyB)-[:HAS_FAMILY_MEMBER]->(childb:Child{name:"childB"}),
(familyB)-[:HAS_FAMILY_MEMBER]->(motherb:Mother{name:"motherB"}),
(familyB)-[:HAS_FAMILY_MEMBER]->(fatherb:Father{name:"fatherB"}),
(fatherb)-[:PARENT_TO]->(childb),
(motherb)-[:PARENT_TO]->(childb)
CREATE (familyA)-[:IS_NEIGHBOUR_TO]->(familyB),
(familyB)-[:IS_NEIGHBOUR_TO]->(familyA)
from neo4j.
Thanks for the feature request. I will close this issue now and we will let you know when we have more information. Please let me know if there is anything else we can help you with.
from neo4j.
@flyly0755 does the suggested model work for your use-case? (that is: to create a node which represents the node-set) Is there something a node-set can provide than a node representing a node-set can not?
from neo4j.
@flyly0755 Ok, now I think I understand your question/feature-request π
I will add it as a feature request. The only thing I can come up with that you could do today, is that you could create a node which is the node-set (in this case it would then be to create family nodes):
Or in cypher:
CREATE (familyA:Family{name:"familyA"}), (familyA)-[:HAS_FAMILY_MEMBER]->(childa:Child{name:"childA"}), (familyA)-[:HAS_FAMILY_MEMBER]->(mothera:Mother{name:"motherA"}), (familyA)-[:HAS_FAMILY_MEMBER]->(fathera:Father{name:"fatherA"}), (fathera)-[:PARENT_TO]->(childa), (mothera)-[:PARENT_TO]->(childa) CREATE (familyB:Family{name:"familyB"}), (familyB)-[:HAS_FAMILY_MEMBER]->(childb:Child{name:"childB"}), (familyB)-[:HAS_FAMILY_MEMBER]->(motherb:Mother{name:"motherB"}), (familyB)-[:HAS_FAMILY_MEMBER]->(fatherb:Father{name:"fatherB"}), (fatherb)-[:PARENT_TO]->(childb), (motherb)-[:PARENT_TO]->(childb) CREATE (familyA)-[:IS_NEIGHBOUR_TO]->(familyB), (familyB)-[:IS_NEIGHBOUR_TO]->(familyA)
thank you so much for your detailed explain, yeah, which is great, everything is represented as point to point relationship:)
from neo4j.
At the same time, I think of another question, the relationship between child and parents, now with neo4j is triangle model(3 points, 3 edges). But is there a new represention like T model? showed as below:
father---------mother
|
|
|
child
from neo4j.
@flyly0755 I'm not sure I understand your question, so please let me know if I have misunderstood anything. You could create the T-model as:
father----family-----mother
|
|
|
child
In my example above, you would do that by removing the relationships between mother-child and father-child. Note however that you would need to have four nodes:
- Family
- Mother
- Father
- Child
This because a relationship always is connected to exactly 2 nodes. So you could get a T model, but with 4 nodes. Does that answer your question?
from neo4j.
What i want to express is whether we can think out of the box:)
Now relationship can be created only between 2 nodes.
Maybe we can consider relationship between a node and a relationship.
father<----matrimony----->mother
|
result
|
v
child
matrimony is relationship between father and mother intead of a node.
and result is relationship between matrimony and child.
from neo4j.
@flyly0755 maybe that is something that could be done in the future, but nothing that we have any plans to do right now.
For now, you can get similar behaviour by adding a matrimony
node. I'm sorry, but I can't really see why you would need a "hyper relationship" (relationship connecting to more than 2 nodes). If you have a very good use-case for it (where it's not possible to model the "hyper relationship" by adding one or more nodes), then please let me know :)
from neo4j.
yeah, hyper relationship, good concept.
For example, addition, subtraction, division and multiplication in math,
num1 (+-*/) num2 = result, so num1, num2 and result these 3 numbers relationship is hyper relationship.
from neo4j.
Related Issues (20)
- Mounted config to docker image has strange behaviour
- neo4j:4.4-community can not run correctly HOT 6
- Merge doesn't create relationship through composite database HOT 1
- Neo4j unexpectedly terminates connection with Java
- In corrupt relation HOT 1
- Can Create Properties with hyphens, but not delete HOT 1
- can not connect to neo4j HOT 1
- Neo4j Vector Index - Increase dimension limit to 8192 HOT 4
- The version 5.23.0 of Neo4j is not compatible with the version 2.8.0 of GDS. HOT 2
- Property of node is missed in return result HOT 4
- Neo4j Desktop (1.6.0) not showing the latest neo4j version (5.23) HOT 2
- Destructuring assignment using `WITH ... AS` Pretty Please! HOT 3
- Where can I find GenAI plugin for neo4j community in version 5.23? HOT 7
- Comparison of dates in different Time Zone representations does not work as expected HOT 9
- timezone conversion causes RangeIndex miss HOT 1
- Different results due to adding CREATE HOT 2
- Cypher query returns empty set instead expected values HOT 2
- neo4j.com is down HOT 1
- canβt open neo4jβs official website
- Unintended JSON string conversion in property values HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neo4j.