归档理论
我即将建立一个新的数据库,其中需要包含仍可访问的记录的存档。记录都与某些项目相关联,当项目存档时,我希望记录保持不变,即快照。 (例如,如果联系人与存档项目关联,并且他们在一年后搬家,我希望它仍然提取旧地址。)存档记录不需要更新,但确实需要可访问。
我知道如何解决这个问题,但我不确定这是否是最好的方法:每个表都有一个副本,可以“存档”所有内容,然后在将项目存档时,所有 FK/PK关系将会更新,尽管这似乎是一个繁琐的过程。
我的另一个想法是每个项目(即联系人)都会分配一个 PK,然后每个项目都有一个辅助密钥,然后与每个项目相关联。这样做的主要问题是,如果联系人在实时项目上进行更新,则需要进行大量更新,这似乎很困难。
如果您有任何疑问,请告诉我。
谢谢你的帮助。
I am about to set up a new database that will need to include archiving of records that are still accessible. Records are all associated with certain projects and when the project is archived, I want the records to stay the same, a snapshot. (e.g. If a contact is associated with an archived project, and they move a year later, I want it to still pull the old address.) The archived records do not need to be updated, but they do need to be accessible.
I have an idea of how to go about this, but I am not sure if this is the best approach: Have a duplicate of each table that would "archive" everything, and then when putting an item in archive, all the FK/PK relationships would be updated, though that seems like a cumbersome process.
Another idea I had was each item (i.e. contact) would be assigned a PK and then there would be a secondary key for each item which would then be associated with each project. The main problem with this is it seems difficult if a contact updates on a live project, a lot of updates would be required.
Please let me know if you have any questions.
Thank you for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯......我唯一一次遇到这样的事情,有想法在应用程序层解决它,而不是在数据库上。
例如,对于 ruby,您可以使用lvestal_versions 或paper-trail。
例如,Paper-trail 将所有对象的版本作为序列化对象存储在一张表上,并使用增量。
Hm... The only time I came accross with something like this, there was the idea to solve it in the application layer, and not on the db.
For instance, for ruby, you may use vestal_versions or paper-trail.
Paper-trail, for instance, stores the versions of all objects as serialized objects on one single table, and works with deltas.
您正在寻找的是在域数据旁边包含时态数据。这类事情并不是一项简单的任务,而且通常会导致需要支持它的应用程序变得非常复杂。
有多种方法可以实现此目的,每种方法都有其优点和缺点,您选择的方法将取决于您需要对数据的时间元素执行什么操作。其中一些包括:
Martin Fowler 写了一些与设计处理时态数据的模型相关的文章,因此我将从这里开始,为该主题打下良好、坚实的基础。
What you are looking for is to include temporal data along side your domain data. This sort of a thing isn't a trivial task to undertake and is often the cause of great complication in applications that need to support it.
There are a number of ways to go about doing this, each with their pros and cons, and the way you choose will depend on what you need to do with the temporal element of your data. Some of these include:
Martin Fowler has written some articles relating to designing models that deal with temporal data, so I would start there for a good, solid grounding in the topic.