Hi, I am working on an application for storing family trees. From what I have read in a book about graph databases/neo4j is that the relationships should not be duplicated.
@Node("Person")
class Person(
val firstName: String,
val lastName: String,
) {
@Id @GeneratedValue
var personId: Long = -1
@Relationship(type = "CHILD_OF")
var parents: MutableSet<Person> = mutableSetOf()
@Relationship(type = "PARTNER_OF")
var partners: MutableSet<Person> = mutableSetOf()
@Relationship(type = "PARENT_OF")
var children: MutableSet<Person> = mutableSetOf()
}
For example if there exists a relation such as (a)-[PARTNER_OF]->(b) , then (b)-[PARTNER_OF]->(a) would be useless, because it can be easily queried both directions even though the relation is oriented. For example:
MATCH (p: Person) WHERE id(p) = ${personId}
OPTIONAL MATCH (p)-[rel:PARTNER_OF]-(other)
RETURN p, rel, other
Yes, you could use of course your own query.
Best would be something like MATCH (person:Person)-[partnerOfRelation:PARTNER_OF]-(partner:Person) RETURN person, collect(partnerOfRelation), collect(partner).
You might be interested in a PlugIn being developed for genealogy. It will upload a GEDCOM into Neo4j. It also imports DNA results and has functions for genetic genealogy analytics. I'm writing the documentation now. If you send me an email, I'll communicate more about this when I get back from my current travels on Friday.