I don't know what is the term it used to define this problem, let me explain here with a simple example. I have a products
and orders
table, with orders
having one to many relationship with ordered_products
table.
See the tables:-
products(id, sku, name, summary, price);
orders(id, code, customer_name, customer_address);
ordered_products(id, order_id, product_id, quantity);
Once the orders are generated, the ordered products are listed in the ordered_products
table. The application then generates an invoice at that instance taking the price reference from the products
table. Problem occurs! when the product that has been ordered get edited. For example if name or price is edited on the products
table, the orders is affected creating a mismatch in actual orders. What's the solution here? Do I need to copy the values in the ordered_items
rather than using a foreign key reference here?
订单通常以约定的价格下单,因此下订单后更改产品价格确实意味着您必须将ordered_price存储在ordere_products表中。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.