Answer the question
In order to leave comments, you need to log in
What is the best way to store a list of items in an order?
Hello.
What is the best way to store data about the items included in the order, if it is expected that the purchased items will change over time, but the data of the items in the order must remain unchanged?
Example:
Placed Order1, which contains Product1 with a cost of 100 rubles.
The Order1 page displays Item1 with a cost of 100 rubles.
The administrator changed the cost of Item1 by 200 rubles.
On the Order1 page, Product1 should be displayed with a cost of 100 rubles, not 200.
The first thing that comes to mind is to store a full or partial copy of the purchased product at the time of placing the order, so the data for displaying the product will be taken from the copy and changes in the main product will not affect the composition of the order. However, this solution has an obvious disadvantage.
How do you solve such problems?
Answer the question
In order to leave comments, you need to log in
The first thing that comes to mind is to store a full or partial copy of the purchased product at the time of placing the order.Another option is to use Event Sourcing, but it has the same problems, plus the fact that you need to redo the entire application for it. Or just keep a log of changes and get a cut at the right time - Event Sourcing at the minimum.
1. Keep a history of product changes
2. Before buying, check if the current copy of the product has gone to the archive
3. Warn users if something has changed
4. The entire order is paid for the full amount, so it doesn’t matter if the cost has changed since the start of the payment single item
Profit
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question