graphtime-seriesorientdb

OrientDB Time Series Data


I have seen the example of using OrientDB to model time series data but I don't know what the insertion looks like.

It would be great if somebody had an example for this.

Regards, Tom

https://github.com/orientechnologies/orientdb/wiki/Time-series-use-case


Solution

  • to get a clearer idea of the utility of the Time Series, you could imagine this casuistry:

    You have a given log related to a certain date. In the case where the DB had millions of records, a search through the date field would be very expensive as it would force the query to read all the records and check the condition, while with the time series filtering takes place at each passage between connected classes ( years, months, hours and then logs), so after going to read only the records that match the date and not all the others.

    Following a small example:

    CREATE CLASS Year extends V
    CREATE CLASS Month extends V
    CREATE CLASS Day extends V
    CREATE CLASS Hour extends V
    CREATE CLASS Log extends V
    
    CREATE PROPERTY Year.value STRING
    CREATE PROPERTY Year.month LINKMAP Month
    CREATE PROPERTY Month.day LINKMAP Day
    CREATE PROPERTY Day.hour LINKMAP Hour
    CREATE PROPERTY Hour.log LINKSET Log
    
    CREATE VERTEX Log SET priority='high'
    CREATE VERTEX Log SET priority='medium'
    CREATE VERTEX Log SET priority='low'
    
    INSERT INTO Hour(log) VALUES ([#16:0,#16:1])
    INSERT INTO Hour(log) VALUES ([#16:2])
    INSERT INTO Day(hour) VALUES ({'15':#15:0})
    INSERT INTO Day(hour) VALUES ({'10':#15:1})
    INSERT INTO Month(day) VALUES ({'4':#14:0})
    INSERT INTO Month(day) VALUES ({'21':#14:1})
    INSERT INTO Year(value,month) VALUES ('2012',{'3':#13:0})
    INSERT INTO Year(value,month) VALUES ('2015',{'8':#13:1})
    

    Query 1: Find all the logs related to the date 4/3/2012 h15

    SELECT EXPAND(month[3].day[4].hour[15].log) FROM Year WHERE value='2012'
    

    Query 2: Find all the logs related to the date 21/8/2015 h10

    SELECT EXPAND(month[8].day[21].hour[10].log) FROM Year WHERE value='2015'
    

    Hope it helps