I'm trying to model when British football managers were hired and fired by their clubs and came up with the following model:
Tenure-[:HIRED_ON]-date1
Tenure-[:FIRED_ON]-date2
Tenure-[:MANAGER]-manager
Tenure-[:TEAM]-team`
I've got a dummy data set here -> http://console.neo4j.org/?id=nmeaef
The data modelling style is taken from -> http://docs.neo4j.org/chunked/snapshot/cypher-cookbook-path-tree.html#cookbook-return-partly-shared-path-ranges
What I'd like to do is find who the manager for a team was on a certain date and if they didn't have a manager then it should indicate that.
So on the 2nd January in my data set both clubs have a manager as neither has been fired yet and this query works ok:
START team = node:node_auto_index('name:"Chelsea" name:"Manchester United"'),
startDate = node:node_auto_index(name="2nd")
MATCH startDate<-[:NEXT*0..]-day
WITH team, startDate, COLLECT(day) AS dates
MATCH startDate<-[:NEXT*0..]-day<-[hire:HIRED_ON]-tenure-[:MANAGER]->manager,
tenure-[:TEAM]->team, tenure-[?:FIRED_ON]-dateFired
WHERE dateFired IS NULL OR NOT dateFired IN dates
RETURN team.name, manager.name, tenure, hire.date, dateFired
But on the 5th January it doesn't work as I want because by that date the Chelsea manager has been fired so I want to indicate that they don't have a manager but instead what happens is I just don't get a row for Chelsea because I've filtered it out with the WHERE clause.
But without the WHERE clause it suggested Mourinho is manager which isn't right either since he was fired on the 3rd January.
Any ideas on how I can do what I want? Should I be modelling it differently to do that?
Cheers, Mark