# Count Unique Entries in Database to Graph

**URL:** https://discourse.nodered.org/t/count-unique-entries-in-database-to-graph/96717
**Category:** General
**Tags:** database, dashboard
**Created:** [23 April 2025 12:05 UTC](https://discourse.nodered.org/t/count-unique-entries-in-database-to-graph/96717 "2025-04-23T12:05:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![LetsDoIt](https://avatars.discourse-cdn.com/v4/letter/l/a8b319/32.png) [@LetsDoIt](https://discourse.nodered.org/u/LetsDoIt)
#### Post date: [23 April 2025 12:05 UTC](https://discourse.nodered.org/t/count-unique-entries-in-database-to-graph/96717/1 "2025-04-23T12:05:54Z")

</div>

Hi folks,

I've resurrected an old project and I need a little help please.

Long story short, I've installed Node Red on a phone. I've managed to get it to use a motion detection app to take photos and put them in a folder. Node Red then uses an API to upload the photos to an object recognition site which returns a JSON detailing what it "sees". I am going to point this as my bird feeder to identify the visitors. I have got the system to email me photos and even "text to speech" announce what is on the feeder.

Phase 2 is to write each visitor into a database with fields being as follows:

Time\_Taken (The time the alert was detected)  
Visitor\_Name (The name returned from the API)  
Photo (Base64 copy of the photo taken)

I would then like to count each of entry for a unique Visitor\_Name and pass this to the dashboard so I can have a bar graph showing the number of visits for each type of bird.

For example, a robin gets captured so it is logged in the database. It might come back again so it is logged again. The graph would then have a bar for "Robin" with a value of 2. A Starling then arrives and is logged in the database and the graph automatically has a bar for "Starling" with a value of 1.

I don't know anything about Databases in Node Red, so my questions are as follows:

1. How do I set up a persistent database file which would survive reboots?
2. How do I count the unique values entered into the database and pass the unique names and the number of times they exist over to the dashboard?

Hope this all makes sense - please ask if I'm talking gibberish!

Cheers, K.

TL;DR : How do I count unique entries in a database and dynamically update a graph on the dashboard with the name and count value, even when new unique values are added?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [22 July 2025 12:06 UTC](https://discourse.nodered.org/t/count-unique-entries-in-database-to-graph/96717/2 "2025-07-22T12:06:50Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
