# How to effectively use InfluxDB

**URL:** https://discourse.nodered.org/t/how-to-effectively-use-influxdb/36885
**Category:** FAQs
**Tags:** database
**Created:** [2 December 2020 16:40 UTC](https://discourse.nodered.org/t/how-to-effectively-use-influxdb/36885 "2020-12-02T16:40:15Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [2 December 2020 20:56 UTC](https://discourse.nodered.org/t/how-to-effectively-use-influxdb/36885/5 "2020-12-02T20:56:48Z")

</div>

> [@StefanSchmelz](#):
>
> About 3. : I need to decide if it would be wiser to store all temperatures inside one measurement, all humanities in one measurement and so on or if I Store all sensor values from the living room in one, all from the kitchen in one and so on....

- An InfluxDB `measurement` is similar to an SQL database table.
- InfluxDB `tags` are like indexed columns in an SQL database.
- InfluxDB `fields` are like unindexed columns in an SQL database.
- InfluxDB `points` are similar to SQL rows.

So I have a database called `domotica` with the following measurements:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/c/9ca720e6e9c074bb3824e2c6954b887afa11bc38.png)

- The `environment` measurement contains all of my sensor data
- I have a couple of tags: `location` and `type`
  - Location tags are real places such as "Kitchen"
  - type tags are sensor measurement types such as "Temperature", "Humidity", "Light", etc.

- I typically have only 1 field called `value`

Typically a tag will contain text, a field will contain a number. Try to make sure you get that right because correcting the data type of a field is a right pain.

Here are some example retention policies

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/b/ebe26838ceba44a3d386b2e7cccaa4438ec27d2e.png)

You may wish to accumulate long-term data into another measurement within your database with a continuous query such as:

CREATE CONTINUOUS QUERY cq\_60min ON domotica BEGIN SELECT mean(value) AS value, max(value), min(value), max(value) - min(value) AS range INTO domotica.one\_week.env\_daily FROM domotica.twenty\_four\_hours.environment GROUP BY location, type, time(1h) END

Which summarises the 1 minute sensor values from `domotica.twenty_four_hours.environment` which are kept in that measurement for 1 week - into hourly values in `domotica.one_week.env_daily`, keeping average, max and min values for each 1hr time period.

---

_[View the full topic](https://discourse.nodered.org/t/how-to-effectively-use-influxdb/36885)._
