What is difference between:
OPTIONAL MATCH a->b
OPTIONAL MATCH b->c
OPTIONAL MATCH b->d
OPTIONAL MATCH a->b, b->c, b->d
I see difference in result in case a->d returns null.
The first version returns a,b,c
The second version returns a.
The OPTIONAL MATCH considers the entire pattern, or all subpatterns as a whole, in the case of your second query. So in your second query if 2 of the subpatterns are present but the 3rd (
b->d) is not, then the entire pattern was not found, and you'll get nulls for all the new variables.
In contrast, your first approach considers each of the patterns separately, so the optional matching of one is not dependent upon the optional matching of another (excepting that the last two optional matches are dependent on
b from the first optional match).
I expected this but hoped that there is diff:
OPTIONAL MATCH a->b->c
OPTIONAL MATCH a->b, b->c