logoalt Hacker News

throwaway7783yesterday at 6:08 PM2 repliesview on HN

Works when there is always an active price. Having an explicit end date allows certain rows to be inactive automatically after validity period. Think of seasonal categories/products etc which dont exist after a specific period


Replies

promanoyesterday at 6:25 PM

And even if you don't have seasonal products, you still need an end date to mark when you stop selling a product; otherwise you have to do something hacky like defining "<price> = NULL means we stopped selling the product after <valid_from>" and inserting an extra record.

I think the end date should be nullable though, but valid_to is NOT NULL in the starting example... later in the article, when showing the "new way" using date ranges, it inserts a row with an open-ended range, which is more what I'd expect.

larsnystromyesterday at 6:18 PM

You could also make the price column nullable and just insert a row with price null and the date from which there should be no price.

show 1 reply