mark-win commented on PR #1452:
URL: https://github.com/apache/age/pull/1452#issuecomment-2000777633

   This Feature is huge, not only for openCypher compliance. A merge would be 
much appreciated.
   I would like to provide two real life examples, where this is mandatory for 
matching.
   
   I am using graph databases mostly as backend for traditional OLTP 
Applications, as opposed to data analysis. For me the most common use case for 
union style relation type queries is, to enforce constraints on your relations 
by checking for forbidden combinations before creating an edge.
   
   ### Example 1
   Imagine a graph with vertices representing persons `:PERSON` and edges 
representing their relation to one another `:SIBLING, :PARENT, :MARRIED, ...`.
   When trying to add a new edge between two persons, especially when triggered 
by user input, you would probably want to check, if that would violate the 
rules of your application. In this case you might consider denying the action, 
if `(a:PERSON)-[:SIBLING|PARENT *]-(b:PERSON)` exists, before marrying two 
people.
   
   ### Example 2
   Imagine a graph for task planning. Tasks `:TASK` can depend `:DEPENDS_ON` on 
other tasks, to form a chain of execution. But they can also be infinitely 
nested `:SUBTASK_OF` to divide them into smaller chunks of work.
   Before creating any of the two edge types, we need to check, that we don't 
create a circular dependency. In this graph model, it can happen like this:
   ```
   // having
   (a:TASK)-[:DEPENDS_ON]->(b:TASK)
   // each of these would produce a circular dependency for the model:
   CREATE (b)-[:DEPENDS_ON]->(a)
   CREATE (a)-[:SUBTASK_OF]->(b)
   CREATE (b)-[:SUBTASK_OF]->(a)
   ```
   To add to the complexity, any combination of both edge types in any path 
length are a problem and can (within reasonable effort) only be detected like 
this:
   ```
   // again not allowed to exist:
   MATCH p = (a:TASK)-[:DEPENDS_ON|SUBTASK_OF *]-(b:TASK)
   ```
   Almost feels like a prime example for the power of graph databases. And if 
you don't want to use this feature in an OLTP context, you sure want to be able 
to find these conditions in your dataset.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to