I need to store large number of dates, along with with a price that corresponds to each date. I am considering two options: One is (a) to store a row for each date and price pair; the other is (b) to store a row with date range and price. For example:
Option a. A table that stores individual dates
CREATE TABLE Foo
(
ID INT,
Date SMALLDATETIME,
Price DECIMAL
);
Option b. A table that stores date ranges
CREATE TABLE Bar
(
ID INT,
RangeStart SMALLDATETIME,
RangeEnd SMALLDATETIME,
Price DECIMAL
);
Is option (b) really a good idea? The main reason for this is to decrease number of rows INSERTed. In this case, if a price is the same throught a year I would have, e.g.:
ID RangeStart RangeEnd Price
-- ---------- ---------- -----
1 2017-01-01 2017-12-31 100
instead of
ID RangeStart Price
--- ---------- -----
1 2017-01-01 100
2 2017-01-02 100
...........................
365 2017-12-31 100
Is there really a need for this, since there would be an additional overhead of converting date ranges to dates when used at an application program business layer?
where xx >= rangestart and xxx < rangeend