I am setting up a time-based graph database, around the following design principle:
I have a program which is supposed create new time-points (when relevant) in the database. I find the relevant nodes using a binary searchand then attempt to delete existing relationships (if needed) and create new relationships.
The two nodes (204452 and 203838) that I am trying to connect exist and can be retrieved using the following syntax:
MATCH (y1:Year)-[:CONTAINS_MONTH]->(m1:Month)-[:CONTAINS_DAY]->(d1:Day)-[:CONTAINS_TIMEPOINT]->(t1:Time)
where (y1.year='2017' AND m1.month='02' AND d1.day='28' AND t1.time='204452')
return y1, m1, d1, t1
The above queries yield the following subgraphs (showing that the individual queries work, right?)
However, when I try to create the connection using the following query:
MATCH (y1:Year {year:'2017'})-[:CONTAINS_MONTH]->(m1:Month {month:'02'})-[:CONTAINS_DAY]->(d1:Day {day:'28'})-[:CONTAINS_TIMEPOINT]->(t1:Time {time:'203838'}),
(y2:Year {year:'2017'})-[:CONTAINS_MONTH]->(m2:Month {month:'02'})-[:CONTAINS_DAY]->(d2:Day {day:'28'})-[:CONTAINS_TIMEPOINT]->(t2:Time {time:'204452'})
CREATE (t1)-[:NEXT_TIMEPOINT]->(t2)
Nothing happens and the Neo4j website frontend (that I was using to try and identify the issue) gives a warning about a cartesian product. I will admit that I have only recently started working with Neo4j and therefore I will mention what I think what the above query should do:
The first MATCH
line defines and runs the first sub-query, returning the 203838 subgraph. The second MATCH
line defines and runs the second subquery, returning the 204452 subgraph. Lastly, the CREATE
line creates a relationship between the two time nodes acquired via the above sub-queries.
However, as there is nothing happening I assume that my understanding of the above query is wrong and I would like to know Q1. what it actually does and Q2. what would be the correct way to do this?