Name of the product price, line-item database pattern

database-design

What is the database pattern called where (for example) the current price of a product is stored in one table, and when someone makes a purchase the current price of the product is copied to a line item table, and is redundant until the price changes?

Best Answer

Not every approach to common problems has a name. Certainly at least not a commonly agreed name. The term "design patterns" applies just as well to common database designs as it does to OOP. I would say data modellers are a little less enamoured with the idea of design patterns than OOP programmers.

I'm not familiar with a commonly agreed name for the design approach that you're describing. I call it transactional logging.

As an aside, the price in the sale item table is not technically redundant, even if the price hasn't changed. The price in the product table is the current book price, the price in the sale item table is the actual price charged. There is no way of knowing for sure what price was actually charged from looking at book price. Even if you have a book price history table it might have been possible, depending on your system's rules, for the price to be overridden manually. The two data attributes are semantically different, even if they happen to be coincidentally equal for some period of time.

Related Question