I have done my research on SQL Server GraphDB, but all the contrived examples I've found so far use only a single edge table. It's always Person-friend_of->Person, for example. In my case, I've created a graph of deployed software components in our datacentre, and there are different edges/relationships. Things like Application-connects_to->SqlDatabase and Server-hosts->Application.
I want to write a query that will show me the shortest path between any two nodes, regardless of the Edges used. I think if I was using Neo4j, I'd write the MATCH as something like:
Server-*->SqlDatabase Notice the asterisk.
Is there an idiomatic way to do this in SQL Server?
Since SQL Server 2019 you can do exactly that using derived tables or views. I couldn't find any official documentation of this feature, but i found a small remark in a video about Bill of Materials. The problem is, that it is currently (SQL Server 2019) buggy and doesn't work as expected (or as I would expect it to work).
edit: They have some links in that video, but we need to be concerned only with this Github example.
edit 2: I have discovered a major bug, that basically disqualifies heterogenous queries from real-world usage.
The point is that you use a
UNION ALLof multiple EDGE (or NODE) tables to serve as one EDGE (or NODE) table in theMATCHoperator.Example
This example uses heterogenous node view and heterogenous edge view. It also depicts two major (I would call it a bug, but it may be a feature, this is a question for M$ to answer) bugs: