Return a subgraph touched by a query #241
-
Hi -- I just discovered CozoDB and I think it's really an excellent piece of technology! I am working on a problem in AI for financial services. I've previously been using neo4j/memgraphdb and cypher. I feel like datalog/cozo potentially can be a better fit, but I am having problems when it comes to visualizing the subgraphs that were 'touched' by a query. Cypher makes this very easy -- and I am not sure how might be a good way to do the same with Cozo. Here is an example in cozo. There are clients. They have accounts. Accounts have types. Certain clients are eligible for certain account types.
I want to ask "which accounts is Alex eligible for, that they do not already have?" In Cozo it's easily doable as follows:
In cypher, here is the equivalent:
But with a tiny tweak to the cypher query, I can return the entire subgraph (nodes and links) touched by the query:
This ability to easily return nodes and links from a query makes it very easy to visualize (using graph visualization tools) what is going on in the system. Is there a straightforward way to get this same type of information in Cozo? (All links/nodes 'included' in a query result) Thanks Mike |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Have you found a solution? It's my understanding that Datalog-style languages answer queries by repeatedly applying rules to facts until they reach a fixpoint (i.e. the rules don't produce new information), and then the query itself is evaluated. While theoretically it seems possible to keep a record of what rule produced which new fact, it doesn't seem like CozoDB implements this. Instead, as far as I can tell, you need to track this information explicitly yourself, e.g.:
produces:
|
Beta Was this translation helpful? Give feedback.
Have you found a solution? It's my understanding that Datalog-style languages answer queries by repeatedly applying rules to facts until they reach a fixpoint (i.e. the rules don't produce new information), and then the query itself is evaluated. While theoretically it seems possible to keep a record of what rule produced which new fact, it doesn't seem like CozoDB implements this. Instead, as far as I can tell, you need to track this information explicitly yourself, e.g.:
p…