如何在OrderDetails与Product绑定时删除产品并保留订单历史记录。 [英] How to delete products and persist order history when OrderDetails is coupled to Product.

查看:111
本文介绍了如何在OrderDetails与Product绑定时删除产品并保留订单历史记录。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我目前正面临着一点点狂欢。你看我有这个产品/购物车/订单系统。在这个系统中,我将OrderDetails表连接到Product表,其关系为One Product可以有很多OrderDetails。



如果用户想要删除他们的产品之一,我怎么能坚持OrderDetails,以便从删除产品的用户购买产品的任何用户仍将维护所有OrderDetails。我们的想法是将产品与OrderDetails分离,并为OrderDetails表添加冗余。



你有什么想法?如果您需要更多说明,请告诉我!!!



谢谢,

robNo

Hi All,

I am currently facing a little bit of a delima. You see I have this product/shopping cart/order system. In this system I have the OrderDetails table coupled to the Product table with a relationship of One Product can have many OrderDetails.

If a user wanted to delete one of their products, how could I persist the OrderDetails so that any user that purchased a product from the user that deleted the product will still maintain all of the OrderDetails. A thought is to decouple Products from OrderDetails and add redundancy to the OrderDetails table.

What are your thoughts? Let me know if you need more clarification!!!

Thanks,
robNo

推荐答案

您需要保留历史记录。也许是无限期的。



您需要一个逻辑删除标志,通常是Bit数据类型列,其名称类似于ActiveProduct。



客户可以购买的有效产品将具有ActiveProduct列= 1.当要从当前产品目录中删除产品时,该产品的ActiveProduct列设置为0的所有选择代表客户执行的语句作为 Where 子句的一部分,附加条款:

You need to keep history. Perhaps indefinitely.

You need a "logical" deletion flag usually a Bit data type column with a name like "ActiveProduct".

An active product that customers can buy would have the ActiveProduct column = 1. When a product is to be deleted from the current product catalog, the ActiveProduct column for that product is set to 0. All Select statements that execute on behalf of customers have as part of their Where clause, the additional clause:
AND ActiveProduct=1


这篇关于如何在OrderDetails与Product绑定时删除产品并保留订单历史记录。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆