-- basicly we need one table for store price changes history
CREATE TABLE price_history (
id serial,
price_date timestamp,
price numeric
);
-- for ability to store separated prices for different products
-- we need to create table products
CREATE TABLE products (
id serial primary key,
name varchar
);
-- and add column product_id into price_history
ALTER TABLE price_history ADD product_id int REFERENCES products(id);
-- add index for select performance
CREATE INDEX price_history_product_id_ix ON price_history(product_id);
-- because same product can have differen price at different suppliers
-- we do next iteration
CREATE TABLE suppliers (
id serial primary key,
name varchar
);
ALTER TABLE price_history ADD supplier_id int REFERENCES suppliers(id);
CREATE INDEX price_history_supplier_id_ix ON price_history(supplier_id);
-- same way we will add all parameters as city, devivery, and so on