Search code examples
influxdb

Using influxdb on a use case with HR hierarchy


I have a use case that I wonder if I can use time-series database, InfluxDB.

The case can be simplified like

  • at T1, user A make a phone call
  • at T1, user B make a phone call
  • at T2, user C make a phone call
  • at T3, user A make a phone call
  • at T4, user D make a phone call

The HR Hierarchy is

  • M>C>B>A
  • M>D

That is, A reports to B; B reports to C; C reports to M; D reports to M

I want to know, with the time range from T1 to T4,

  1. how many phone calls made from the team under C including C; in this case, the answer is 4.
  2. how many phone calls made from the team under M including M; in this case, the answer is 5.

In the reality, the requirement can be more complicated. For example, show the chart of how many phone call made per day within the last three months.

My question is that, for this use case, if it is reasonable to use InfluxDB. If yes, how am I going to structure the data?

Thank you in advance for the comments and suggestions.


Solution

  • This is time series data and it is reasonable to use a time series DB, such as InfluxDB, for that.

    But there's really only one way of structuring data in influxdb which is a plain table of fields and tags and the influx query language cannot do what you want regardless of structure.

    It may be possible to do it with Flux https://docs.influxdata.com/flux/v0.36/ which is a new scripting language for querying influxdb.

    Or you can try and implement the logic "outside" the database in some programming language.

    There are some relational time series databases that may be more suitable for your case.