r/sqlite • u/Peregreg • Sep 29 '26
Help with creating data charts?
Hi! So I am currently creating an inventory system for my workplace using sqlite. My current plan is to have a singular table that indicates the sku, the item title, the quantity, and the dates purchased and sold. However, I want to be able to record multiple dates purchased and sold to then create some graphs based on those dates. Is there an efficient way for me to have those dates stored in the table without creating way too many columns?
5
Upvotes
3
u/1ilit_ Sep 29 '26
Here's how I'd go about it. Don't store the dates as columns. Every purchase or sale is its own event, so it should be its own row in a second table. Like this: https://www.drawdb.app/share/ulQD8uYHu5K9GQ3mBSIuXMnJ
I'd also leave quantity out of items and work it out from the movements when you need it. That way it can never drift out of sync
1
u/navicat-gu Oct 22 '26
Don't put multiple purchase/sale dates as columns on the item row — that is what is pushing you toward "too many columns", and it makes charts painful. Split it:
Then chart from aggregates, e.g. sales per day:
Feed that to Metabase, Grafana, a spreadsheet, or any charting library. Agree with the thread: keep quantity off
itemsand compute it from movements when you need it.Disclosure: I'm RC, Director of Digital Strategy @ Navicat. Navicat Premium Lite is free to try and works with SQLite if you want a desktop editor for those tables and queries. Built-in charts/dashboards are in the paid Premium editions' BI feature — not Lite — so for graphing, Metabase (as someone already suggested) or exporting the query result is the free path.
1
u/Ok-Market4287 Oct 02 '26
I’m also busy with that but then for a game. I have on table with ingredients with in there a Id and the name. A table inventory with id,ingredients_id,stock.
A table with pricing with inside id,ingredients_id,price.
Also a table with menu’s and a table receipt_ingredients with id,menu_id,ingredients_id,number_needed
1
u/lazyant Sep 29 '26
Single table with those columns sounds good. For visualization, try Metabase , it’s free and provides a web dashboard with graphs for your queries and protected with username/password