Question

I am trying to design a database for a price comparison application, where I get data from different stores of a similar products, so my database needs to compare a price of the same product from different stores and also track the price trends of a product in a specific store over time.

I am using mysql in building the db.

I need help with the design of the database so that my database will be easy to maintain when it scales up with data, insights of all best practice suggestions are also welcome.

Below is the designs I have done where I have three tables which is Product, Price and Store on the first design, on the second design I have two tables which are Products and Store, I'm just unsure whether I should create Prices as fields in the product table or I should create Price as a table, so that I can keep track of a product's price history and to avoid redundancy.

First Design enter image description here

Second Design enter image description here

Was it helpful?

Solution

Probably a separate PriceHistory table is better from a normalization standpoint.

But some ERP systems do additionally store the active / current Price on the Products table too. Up to you how you want to split it, but a dedicated PriceHistory table with an IsActive or IsLatest field for explicity makes the most sense.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top