Doom9527 / aristotle-webservice

👑 A web servide enables you to create knowledge graph.
https://aristotle-ws.com
15 stars 0 forks source link

Support complex data type on node properties #30

Open QubitPi opened 2 months ago

QubitPi commented 2 months ago

[!NOTE]

This is a followup of https://github.com/paion-data/aristotle/issues/23

One of the reasons why many people use yahoo Elide is its ability to support arbitrarily complex entity graph in a single entity attribute. This useful feature maps successfully between business domain data and its database representation in SQL.

This is something Aristotle will do as well, because our application is now facing the same issue of mapping the business data into the database representation.

On nearly half of our nodes, there is a "table property". For example, suppose we have a node with the following attributes (I'm presenting it in YAML):

  - term: der Gegenstand
    definition:
      - object
      - thing
    declension:
      - ["",         singular,                    plural      ]
      - [nominative, Gegenstand,                  Gegenstände ]
      - [genitive,   "Gegenstandes, Gegenstands", Gegenstände ]
      - [dative,     Gegenstand,                  Gegenständen]
      - [accusative, Gegenstand,                  Gegenstände ]

[!TIP]

The data above become a sub-graph of 3 nodes, we can see what our production data looks like by following these steps

  1. Go to "Viewing Our Production Data in Docker" and follow the steps there
  2. Execute this query: MATCH (term:Term)-[r]-(x) WHERE term.name = "der Gegenstand" and term.language = "German" RETURN term, r, x
  3. We should be able to see something like this:

page 3

2 attributes (term, declension) above represents 2 node properties. The declension table is the same thing as the table below

singular plural
nominative Gegenstand Gegenstände
genitive Gegenstandes, Gegenstands Gegenstände
dative Gegenstand Gegenständen
accusative Gegenstand Gegenstände

Knowing that Neo4J does not support object property, we flatten out each table cell, each one of which is a Neo4J node property. For example,

term: "der Gegenstand" declension-0-0: "" declension-0-1: "singular" declension-0-2: "plural" declension-1-0: "nominative" declension-1-1: "Gegenstand" declension-1-2: "Gegenstände" declension-2-0: "genitive" declension-2-1: "Gegenstandes, Gegenstands" declension-2-2: "Gegenstände" declension-3-0: "dative" declension-3-1: "Gegenstand" declension-4-2: "Gegenständen" declension-4-0: "accusative" declension-4-1: "Gegenstand" declension-4-2: "Gegenstände"

This makes the decoding at frontend pretty wacky. Considering we might have 2- or 3-level nested structure in the future, this approach needs to be improved sooner rather than later.

With this issue, the Aristotle is facing an opportunity to become a more useful product than just being a database proxy - mapping business domain model to database representation and vice versa. We should make Aristotle support complex data on node property from the frontend perspective.