How to connect an answer relationship to its question relationship?

I want to create a knowledge management system, illustrated by the following example.

Violet nodes are classes. Green nodes are instances.
Red arrows are subclass relationships. Gray arrows are instance relationships.
Blue arrows are questions. Green arrows are answers.
(The direction of Q&A does not really matter.)

The main point is, that a node inherits the questions and answers from all its ancestors.
So in the GUI view of a node, all Q&A pairs will be shown, as well as all unanswered questions.

The following code is my first attempt to model this. The names are the only thing that identifies the questions, and also the only thing that connects Q&A. This feels wrong to me. (Eventually I would use IDs instead of names, but that does not seem much better.)

// class nodes
CREATE (City:Class {name:'city'})
CREATE (Country:Class {name:'country'})
CREATE (Sea:Class {name:'sea'})
CREATE (PortCity:Class {name:'port city'})
CREATE (FrenchPortCity:Class {name:'French port city'})

// instance nodes
CREATE (LaRochelle:Thing {name:'La Rochelle'})
CREATE (Marseille:Thing {name:'Marseille'})
CREATE (France:Thing {name:'France'})
CREATE (Atlantic:Thing {name:'Atlantic'})
CREATE (Mediterranean:Thing {name:'Mediterranean'})


CREATE

  // subclass relations
  (PortCity) -[:SUB]-> (City),
  (FrenchPortCity) -[:SUB]-> (PortCity),
  
  // instance relations
  (LaRochelle) -[:INST]-> (FrenchPortCity),
  (Marseille) -[:INST]-> (FrenchPortCity),
  (France) -[:INST]-> (Country),
  (Atlantic) -[:INST]-> (Sea),
  (Mediterranean) -[:INST]-> (Sea),
  
  // questions
  (City) -[:QUEST {name: 'city part of country'}]-> (Country),
  (Country) -[:QUEST {name: 'country access to sea'}]-> (Sea),
  (Country) -[:QUEST {name: 'country borders country'}]-> (Country),
  (PortCity) -[:QUEST {name: 'port city access to sea'}]-> (Sea),

  // answers
  (FrenchPortCity) -[:ANS {quest: 'city part of country'}]-> (France),
  (LaRochelle) -[:ANS {quest: 'port city access to sea'}]-> (Atlantic),
  (Marseille) -[:ANS {quest: 'port city access to sea'}]-> (Mediterranean),
  (France) -[:ANS {quest: 'country access to sea'}]-> (Atlantic),
  (France) -[:ANS {quest: 'country access to sea'}]-> (Mediterranean);

The following queries can be used to find all the questions and answers for Marseille:
(Only classes can ask questions. Typically instances answer questions. But classes can too.)

This finds the ancestors, i.e. "French port city", "port city" and "city".

MATCH
    (thing:Thing {name: 'Marseille'}) 
    -[:INST]->
    (parent:Class)
    -[:SUB*0..]->
    (ancestor:Class)
RETURN ancestor;

And these are the connected questions:

MATCH
    (thing:Thing {name: 'Marseille'})
    -[:INST]->
    (parent:Class)
    -[:SUB*0..]->
    (ancestor:Class)
    -[quest:QUEST]-
    (:Class)
RETURN quest.name;

╒═════════════════════════╕
│quest.name               │
╞═════════════════════════╡
│"port city access to sea"│
├─────────────────────────┤
│"city part of country"   │
└─────────────────────────┘

This finds the ancestors, and Marseille itself:

MATCH
    (thing:Thing {name: 'Marseille'})
    -[:INST*0..1]->
    (selfOrParent)
    -[:SUB*0..]->
    (selfOrAncestor)
RETURN selfOrAncestor;

And these are the connected answers:

MATCH
    (thing:Thing {name: 'Marseille'})
    -[:INST*0..1]->
    (selfOrParent)
    -[:SUB*0..]->
    (selfOrAncestor)
    -[ans:ANS]-
    (ansThing:Thing)
RETURN ans.quest, ansThing.name;

╒═════════════════════════╤═══════════════╕
│ans.quest                │ansThing.name  │
╞═════════════════════════╪═══════════════╡
│"port city access to sea"│"Mediterranean"│
├─────────────────────────┼───────────────┤
│"city part of country"   │"France"       │
└─────────────────────────┴───────────────┘

So I have a list of questions and a list of answers, and only need to compare them to find unanswered questions. (In this case none.)

This works. It just does not feel right. I would prefer a more "official" link between Q&A.
I read about the possibility to reify relationships into nodes.
That would allow a real relationship between Q&A.
Is this what you would do?

If there is anything else that comes to your mind, please let me know.

First, there is no direct way to connect one relationship to another. This would be something like a hypergraph, where an edge could point to another edge, and that's not something you can do with Neo4j.

You could instead have a relationship hold an id or property value for looking up another relationship, and use a relationship index lookup to perform that lookup, but this still feels like a mismatched use case.

You might be pulling this apart a bit too much. You've modeled this beautifully for inheritance...for usage in a system and language that has no concept of inheritance.

Inheritance is a tool to achieve something. Given that it isn't a first-class citizen in this language, do you really need it? What was it you were relying on it to do? Can you do that without it?


Do you actually need to have :Class nodes and this hierarchy? You may be able to do something similar with just node labels.

Do you need to have separate questions and answers? Is it not enough to have the answer embedded in the relationships to the :Thing nodes themselves? What requirement is having separate questions and answers serving?

Can you provide some richer use case examples, with example input, and expected output? Not based on the graph in its current form, but based on the use cases you need to fulfill?

I have created Knowledge management with neo4j on Wikiversity, where I will describe this project in more detail.

The software I want to create would be similar to Wikidata, or the category system of Wikimedia Commons. So questions and answers would usually be created by different users. An answer could be wrong. (In an advanced version of the software, there may even be competing answers, citing different sources.) These are reasons to have answers separate from questions. More importantly, one question could have multiple correct answers. That can already be seen in the example above, where a country has multiple cities. But a clearer example can be seen in the article. Each car requires two employees that are responsible for it. So one question requires two answers.

I am sure now, that I need to reify Q&A into nodes. The main reason is, that the number of connected nodes does not have to be two. Population size would be connected only to city. And city part of country may require additional connections like when or according to whom.

I find inheritance practical, and I see no downsides. It does not need to be part of the language.

I have reified Q&A into nodes. This diagram is the equivalent of the one shown above:

The yellow AQ arrow leads from an answer node (green) to its question node (blue).

The query below finds the Q&A for the node Marseille:

MATCH
    (inst:Inst {name: 'Marseille'})
    -[:INST*0..1]->
    (selfOrParent)
    -[:SUB*0..]->
    (selfOrAncestor)
    <-[:ANS]-
    (ansNode:Ans),
    (ansNode) -[:ANS]-> (farNode),
    (ansNode) -[:AQ]-> (questNode:Quest)
RETURN questNode.name, farNode.name;

╒═════════════════════════╤═══════════════╕
│questNode.name           │farNode.name   │
╞═════════════════════════╪═══════════════╡
│"port city access to sea"│"Mediterranean"│
├─────────────────────────┼───────────────┤
│"city part of country"   │"France"       │
└─────────────────────────┴───────────────┘