Skip to content

Instantly share code, notes, and snippets.

@thomasfr
Last active August 29, 2015 13:57
Show Gist options
  • Save thomasfr/9811893 to your computer and use it in GitHub Desktop.
Save thomasfr/9811893 to your computer and use it in GitHub Desktop.
A Neo4J GraphGist about an attempt to model Office Hours. I want to be abel to ask questions like: "What location has opened now or at a given date and time?" and "Has this location open now or at a given date and time?"
CREATE (locationA:Location{name:"location A"}),
(locationA)-[:hasOfficeHours]->(officeHours:OfficeHours),
(officeHours)-[:year]->(year:Year{value:2014}),
(year)-[:month]->(month:Month{value:3,name:"March"}),

(month)-[:day]->(day24:Day{value:24, name:"Monday"}),
(day24)-[:hasInterval]->(:Interval{from:8,to:12}),
(day24)-[:hasInterval]->(interval2:Interval{from:14,to:18}),

(month)-[:day]->(day25:Day{value:25, name:"Tuesday"}),
(day25)-[:hasInterval]->(:Interval{from:8,to:12}),
(day25)-[:hasInterval]->(:Interval{from:14,to:18}),

(month)-[:day]->(day26:Day{value:26, name:"Wednesday"}),
(day26)-[:hasInterval]->(:Interval{from:8,to:12}),
(day26)-[:hasInterval]->(:Interval{from:14,to:18}),

(month)-[:day]->(day27:Day{value:27, name:"Thursday"}),
(day27)-[:hasInterval]->(:Interval{from:8,to:12}),
(day27)-[:hasInterval]->(:Interval{from:14,to:18}),

(month)-[:day]->(day28:Day{value:28, name:"Friday"}),
(day28)-[:hasInterval]->(:Interval{from:8,to:15})

CREATE (locationB:Location{name:"location B"}),
(locationB)-[:hasOfficeHours]->(officeHours2:OfficeHours),
(officeHours2)-[:year]->(year2:Year{value:2014}),
(year2)-[:month]->(month2:Month{value:3,name:"March"}),

(month2)-[:day]->(day225:Day{value:25, name:"Tuesday"}),
(day225)-[:hasInterval]->(:Interval{from:9,to:12}),
(day225)-[:hasInterval]->(:Interval{from:15,to:18}),

(month2)-[:day]->(day226:Day{value:26, name:"Wednesday"}),
(day226)-[:hasInterval]->(:Interval{from:9,to:12}),
(day226)-[:hasInterval]->(:Interval{from:15,to:18}),

(month2)-[:day]->(day227:Day{value:27, name:"Thursday"}),
(day227)-[:hasInterval]->(:Interval{from:9,to:12}),
(day227)-[:hasInterval]->(:Interval{from:15,to:18}),

(month2)-[:day]->(day228:Day{value:28, name:"Friday"}),
(day228)-[:hasInterval]->(:Interval{from:9,to:15})

RETURN locationA, locationB

Graph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment