及时存储某一时刻的模型关系
我正在开发一个应用程序,允许人们请求为特定工作生成保修。他们提供诸如使用了什么产品等信息...(他们的一些选择是从系统中已有的项目列表中提供的。然后我们根据这些选择为他们生成保修。
我正在努力解决这个概念批准的保修那一刻的快照,当它依赖于可能随时间变化的相关记录时,
我能想到的最简单的方法不是存储与源表(例如product_id)的关系,而是写入另一种方法是不允许从产品表中删除/修改产品,除非没有附加任何保证。指向同一产品的编辑版本?我以前在购物车中这样做过,而且效果很好,我只是有很多关系需要管理,我想知道是否有一种我没有想到的方法?
I'm developing an application that allows people to request a warranty be generated for a particular job. They supply information such as what product was used etc... (some of their choices are provided from a list of items already in the system. We then generate them a warranty based upon those choices.
I'm struggling with the concept of making an approved warranty a snapshot of that moment in time when it depends on related records that may change over time.
The easiest way I can think of doing this is not to store the relationships to the source tables (e.g. product_id) but to rather write the product out as a string. This seems a bit messy. The other way to go is to not allow for the deletion/modification of a product from the products table unless there are no warranties attached to it. Perhaps implementing a 'replaced_with' column that points to an edited version of the same product? I've done this in a shopping cart before, and it's worked pretty well. I just have a lot of relationships to manage and am wondering if there's a way I haven't thought of?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
怎么样:
添加“历史产品表”,其中包含:
与产品表相同的列
填充日期/时间的附加时间戳字段。
产品 ID/时间戳的主键
产品 ID 上的索引
删除/修改触发器/过程:
选择产品的所有保修。
如果有任何保证,则将产品详细信息复制到“历史产品表”,添加主键的第二部分。
对于找到的每个保修,将一条记录插入“产品停产”表中。
这样做的前提是,您可能希望以不同于现行产品的方式处理停产产品的保修。
What about:
Adding in a "historic product table" that has:
The same columns as the product table
An additional timestamp field for the date/time it was populated.
A primary key of product id/timestamp
An index on product id
a deletion/modification trigger/procedure that:
Selects all warranties on the product.
If there are any warranties, then copy the product details to the "historic product table", adding the second part of the primary key.
For each warranty found insert a record into the "product discontinued" table.
This is premised on the basis that you will probably want to deal with warranties for discontinued items differently from those for active products.