Creating a TimeTree in TigerGraph

Creating a TimeTree in TigerGraph

Originally posted on Medium by Shreya Chaudhary. Follow her on Medium and LinkedIn

Why use a TimeTree? How do TimeTrees Work?

TimeTrees are useful if you are looking at data over time. It helps divide your data based on day, month, and year makes it easy to analyse over time. For TimeTrees, we create three new nodes: day, month, and year. Day is connected to month which is connected to year. From there, the existing data is connected to the nodes based on how specific the date is.

TimeTrees in TigerGraph GraphStudio

To create a TimeTree in GraphStudio, add three vertices called Year, Month, and Day. Connect Year and Month with an undirected edge YEAR_MONTH and connect Month and Day with another undirected edge MONTH_DAY. Finally, connect your data to those nodes. Note that in TigerGraph Month and Day are reserved, so we’ll add an underscore right after the word.

Image for post

Format each vertex similar to this

Image for post

You should end up with a schema like this. Next, add your own data to it!

TimeTrees in Giraffle

In Giraffle, we’ll use the same syntax, just in GSQL.

CREATE VERTEX Year_(primary_id year_ STRING)
CREATE VERTEX Month_(primary_id month_ STRING)
CREATE VERTEX Day_(primary_id day_ STRING)
/* All the rest of your vertices */
CREATE UNDIRECTED EDGE YEAR_MONTH_(FROM Year_, TO Month_)
CREATE UNDIRECTED EDGE MONTH_DAY_(FROM Month_, TO Day_)
/* All the rest of your edges */

Now You’re Set!

Adding TimeTrees are as simple as that! Now you can implement them in your own code!

For further reading, check out this resource: http://vis.berkeley.edu/papers/timetree/2006-TimeTree-VAST.pdf