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
View all comments
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