Knowledge management with neo4j

The aim of this page is to create a software using the graph database  (and its query language ).

The approach is, i.e. the nodes are classes and instances.

Class nodes are violet. Instance nodes are brown. Subclass arrows are red. Instance arrows are gray.

Knowledge is represented by questions and answers. Questions come from classes, and they are shown in blue. Answers typically come from instances, and they are shown in green.

Q&A as edges
Here questions and answers are modeled as relationships, i.e. they are shown as arrows between between nodes.

One problem with Q&A as edges is, that the connection between them is flimsy. (See this question in the neo4j forum.)

car, person
There are two questions, that connect the classes car and person:
 * Who is responsible for the car?  There must be two people responsible for each car. One person can be responsible for up to five cars.
 * Who is the driver?  There might be no driver. If there is one, it must be exactly one person, who drives exactly one car.

 The cardinalities are not yet part of the code. The aim is, that the software will highlight unanswered questions for a given node. If the question "Who is responsible for Dodge?" were answered only by "Alice", the question for a second responsible person would still be highlighted. (The question for the driver would be shown less prominently, because a driver is not required.)

city, country, sea
All questions are asked by classes, and all answers are given by instances.

Now the class French port city is introduced. It answers the question asked by city. The instances inherit the answer.

Q&A as nodes
The Q&A are reified into nodes. This allows an explicit relationship between them, shown by yellow arrows. This will also allow questions connected to more than two classes – or to only one.

city, country, sea
And here the subclass French port city is added:

As above, the queries show the Q&A for Marseille:

car, person
In this example the cardninalities are added to the code.

The query for the questions contains the cardinalities. (That for the answers has not changed.)