I'm trying to make this but for a different language. In this language there are different kinds of names for uncles and aunts. We call paternal aunt something else and maternal aunt something else.
I came across a graph database 'neo4j'. I created 5 members. I got this approach to work just like I want. But the problem in this is that I've to create n * (n-1)
relationships. I'm create a full tree here and not just 5 members of a family.
Also, this is more like brute force. I'm creating all the possibilities.
I'm looking for a smarter way to do this. Creating rules like for example Father's sister = paternal-aunt
and Mother's sister = maternal-aunt
I also want queries Father's wife's sister
but don't want to define them separately.
You don't have to create the bidirectional relationships, and you also don't have to create short-cut-relationships, you can just infer the information in the other direction or across multiple steps.
which would then return ["husband","father"] e.g. for an Father-in-Law or ["mother","sister"] for an maternal aunt.
You can then map those tuples either still in cypher (with
case
) or in your python program.You can create functions that establish the rules, e.g.:
These can be arbitrary complex:
It will be a matter of design for which you consider are primary relationships and which are derived. You can probably derive everything from parent child relationships (and marriage).
Prolog is a reasonable choice... For instance I have this small library to draw 'genealogy trees' like this
from this definition (genre definitions are used only to change node' color)
It requires SWI-Prolog and Graphviz.
edit adding some facts
and the rule
we get