in reply to Date Ranges Question

For data which doesn't change regularly enough to warrant implementation via a time-series DBMS, we use a start-date end-date approach in the data modelling, so that in the example case the price on a given date for a product is given by a query like:
SELECT xxx_price FROM price_history WHERE product_id = <query-product-id> AND <query-date> BETWEEN start_date AND end_date
Update: and the code for changing the price updates the entry with an end-date of 31st Dec 9999 (the existing current price record), to an end-date equal to the cessation date inserts a new record with the new price, a start date of the commencement date and the same 31/12/9999 end date as before. The cessation date is the day before the new commencement date unless the datetime is meant to be intraday.

The logical primary key will include the product id, start date and end date, although in practice an artificial primary key of e.g. entry_id may be used for performance purposes.

-M

Free your mind