I need to model a graph in SQL Server using its Graph extensions. Say I have three tables - persons, restaurants and cities. I have one edge table, called "in", a person or a restaurant can be in a city.
Now I want to retrieve all things in New York. In Cypher I could do something like
MATCH (a)-[:in]-(b:city {name: "New York")
RETURN a
Is it possible to do the same in SQL Server with its graph extensions? As far as I could tell, I should do something like
SELECT Person.name
FROM Person In City
WHERE MATCH (Person)-(in)-(City) AND city.name='New York'
UNION
SELECT Restuarant.name
FROM Restaurant In City
WHERE MATCH (Restuarant)-(in)-(City) and city.name='New York'
That can become very verbose when I have 8 different entity types at are in cities.
Is there a way around this?