Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What temporal patterns exist for neo4j or graph databases?

I'm looking for patterns (ideally with advantages/disadvantages) that can be used for databases concerning time.

One I can think of is to have a node representing a point in time or time period.

What others are there? What others have you used?

like image 357
Scott McKenzie Avatar asked Mar 28 '12 00:03

Scott McKenzie


People also ask

What type of database is Neo4j based on?

Neo4j uses a property graph database model. A graph data structure consists of nodes (discrete objects) that can be connected by relationships. Example 1.

What type of graph is Neo4j?

Neo4j is a native graph database, which means that it implements a true graph model all the way down to the storage level. The data isn't stored as a "graph abstraction" on top of another technology, it's stored just as you whiteboard it.

Do graph databases have schema?

A graph database will always have a rudimentary schema consisting of (at least) Vertex and Edge objects, where an Edge can contain data about a particular relationship. The degree to which you can add to this schema varies widely across implementations.


1 Answers

Not a good question for SO

This question is very open-ended, and SO is meant for questions with specific technical answers.

TL;DR: Graph patterns are infinite. Start from the problem, not the possibilities.

Graph patterns are case-specific, not data-type specific

There isn't a set of temporal graph patterns, and even if there was, each pattern would be unique for a specific use-case, and close to useless elsewhere. What you should be asking yourself:

  1. What will my queries need to look like?
  2. What kind of information am I representing?
  3. What information is relevant?
  4. Should it be more granular, or more general?
  5. Time, Date, or Datetime? Microtime? BC?

Context really matters.

Modelling information flow in a datacenter's network? Probably only need seconds and microseconds in a property on the relevant data.

Modelling evolution on the tree of life? Probably don't need anything from Time or even Date, instead using a float and an int for exponential notation, or a single int representing thousands of years.

What is time?

Or at least, what is it to your data?

The three most common patterns I've seen (because they're the most flexible and easiest to work with in queries):

  • Just stick dates or datetimes wherever they're relevant.
  • (cause)-->(event {datetime})
  • (event)-->(datetime) and (datetime)-[:NEXT]->(datetime)-[:NEXT]->(datetime)

However, even with these patterns there are still many open-ended questions. Consider a case of tracking modifications to files...

  • Simply put create and modified dates on the File nodes?
  • Put dates on a relationship between the user and the file?
    • Just a datetime, or read/write and duration?
  • Event itself as a node with start, end, and duration, with relationships to the user and the file, and the change-set applied to the file?
    • Should that event have a relationships between it's chronological neighbors, or should that relationship be kept between the change-sets alone?
like image 167
Tony Chiboucas Avatar answered Sep 21 '22 15:09

Tony Chiboucas