Struggling to visualize how to store price data in database

built

//
BuSo Pro
Boot Camp
Joined
Jan 23, 2015
Messages
1,677
Likes
1,442
Degree
4
So I’ve been struggling lately with how to visualize price data and history in a database.

What I want to do is store different price data on different dates which I can use to plot on a graph.

I’m using Python and JavaScript and will more than likely be using Postgres

My initial thinking was an object so like:

Code:
{product: “example”, price: {dateOne: “$$$”, dateTwo: “$$$”, dateThree: “$$$”}, currentPrice: “$$”, productUrl: “https://url.com”}

Have I got the right idea? I want to have a full 30 days of previous price data.
 
Unless this is some huge dataset, normalized is the way to go.

So two tables:
Products:
ID|Name|URL
ProductPrices
ID|Product_ID|Price|Date
 
Unless this is some huge dataset, normalized is the way to go.

So two tables:
Products:
ID|Name|URL
ProductPrices
ID|Product_ID|Price|Date
I semi-understand. Does it matter if the second table won't store things in order? By that I mean it will add new rows when updated but it will be for different products so the product_IDs will be in different orders?
 
Product order shouldn't matter in ProductPrices as you'll use the product ID to select relevant rows and then order by date.
 
Product order shouldn't matter in ProductPrices as you'll use the product ID to select relevant rows and then order by date.
Yeah I thought so, just wasn't sure if the data had to be in order. thanks for the help @berthier and @Steve
 
Back