logoalt Hacker News

larsnystromyesterday at 6:03 PM5 repliesview on HN

Why are they storing a time period (start and end date) in the first example? Why not just store the date when the price comes into effect? That would make both overlaps and time travel impossible without using any constraints.


Replies

advisedwangyesterday at 6:58 PM

JOINs and other operations become really difficult if you can't evaluate whether a row applies or not based on that row alone.

throwaway7783yesterday at 6:08 PM

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

show 2 replies
yourMadnessyesterday at 8:26 PM

If you sell a product where the customer can buy the future version today (for delivery in the future), that doesn't work.

quotemstryesterday at 6:07 PM

It's a trade-off. If you store both endpoints you can continue to think of rows as order-invariant tuples. If you store only one endpoint, you have to impose a meaningful order on the rows in order for them to make sense.

show 1 reply
warmwafflesyesterday at 7:19 PM

It's a contrived example.