This document discusses representing dates and times in a Neo4j graph database to enable querying events that occur on specific dates or within a date range. It shows how dates can be modeled as nodes connected by relationships, and provides Cypher queries to find events on a single day, between two days, or check if an event occurs on a given date. Mixed property and relationship types are also discussed.
9. find all events for a given range
root (0)
:year_2014
:year_2013
:month_05
Month: 05
:day_24
Day: 24
:happens
Event 1
:next
:happens
Event 2
Year: 2013
:day_25
Day: 25
:day_26
:next
:happens
:month_06
Day: 26
Month: 06
:happens
Event 3
Year: 2014
:month_01
Month 01
10. find all events for a given range
START root=node(0)
MATCH root-[:year_2013]-()-[:month_05]-()-[:day_24]-start,
root-[:year_2013]-()-[:month_05]-()-[:day_26]-end,
start-[:next*0..]-middle-[:next*0..]-end,
middle-[:happens]-event
RETURN event
11. find all events for a given range
root (0)
:year_2014
:year_2013
:month_05
Month: 05
:day_24
Day: 24
:happens
Event 1
:next
:happens
Event 2
Year: 2013
:day_25
Day: 25
:day_26
:next
:happens
:month_06
Day: 26
Month: 06
:happens
Event 3
Year: 2014
:month_01
Month 01
12. find all events for a given range
root (0)
:year_2014
:year_2013
:month_05
Month: 05
:day_24
Day: 24
:happens
Event 1
:next
:happens
Event 2
Year: 2013
:day_25
Day: 25
:day_26
:next
:happens
:month_06
Day: 26
Month: 06
:happens
Event 3
Year: 2014
:month_01
Month 01
13. find all events for a given range
root (0)
:year_2014
:year_2013
:month_05
Month: 05
:day_24
Day: 24
:happens
Event 1
:next
:happens
Event 2
Year: 2013
:day_25
Day: 25
:day_26
:next
:happens
:month_06
Day: 26
Month: 06
:happens
Event 3
Year: 2014
:month_01
Month 01
14. find all events for a given range
root (0)
:year_2014
:year_2013
:month_05
Month: 05
:day_24
Day: 24
:happens
Event 1
:next
:happens
Event 2
Year: 2013
:day_25
Day: 25
:day_26
:next
:happens
:month_06
Day: 26
Month: 06
:happens
Event 3
Year: 2014
:month_01
Month 01
15. find all events for a given range
START root=node(0)
MATCH root-[:year_2013]-()-[:month_05]-()-[:day_24]-start,
root-[:year_2013]-()-[:month_05]-()-[:day_26]-end,
start-[:next*0..]-middle-[:next*0..]-end,
middle-[:happens]-event
RETURN event
16. does an event happen on a certain date?
START event=node(20)
MATCH event-[:day_24]-()-[:month_05]-()-[:year_2013]-()
RETURN event
17. does an event happen on a certain date?
root (0)
:year_2014
:year_2013
:month_05
Month: 05
:day_24
Day: 24
Year: 2013
:day_25
:day_26
Day: 25
Year: 2014
:month_06
Day: 26
Month: 06
:happens
Event 1 (20)
:happens
Event 2
:happens
:happens
Event 3
:month_01
Month 01
18. property vs. relationship type
constructing cypher queries
execution plan cache vs.
property load
creating and deleting calendar
graph
Its not all negative though... I believe delivery is the greatest potential weapon multichannel retailers have against the elephant in the room
The reason Amazon is such a threat is that they have made consumers believe that there are only two reasons to buy online... range and price... conveniently they have a structural advantage in both these areas...
Increase order value
Improve conversion
Happier customers