活动历史存储设计模式
研究案例:
如果我有例如库对象。 图书馆里有书。 每本书都有通用信息,如名称、日期……以及其他一些依赖项,如作者、经销商……
我有 Person 对象。 如果Person读了这本书,那么我想创造新的记录进入历史。
现在的问题是,什么更好:
1)使用 Book 实体及其依赖项中的所有数据在历史中创建静态记录(在这种情况下,如果 Book 将被更改,那么历史将不是实际的)
或
2)Strore依赖于Book对象(在这种情况下历史记录将是实际的,但在每个请求中我必须查看所有依赖项)
我认为Books将被更改
并且历史记录将显示在人物简介。 (这个假设响应将答案1))
但是历史应该基于实际的图书数据吗?或者历史应该有创建历史的日期信息?
书和人只是例子
Study case:
If I have for example The library object.
In the library are books.
Every book have common information like Name, Date, .... And some other dependencies like Autor, Reseller, ....
I have Person object.
If Person read the book, then I want make new record into history.
And now the problem, what is better:
1) Create static record in history with all data from Book entity and his dependencies (In this case If the Book will be changed, then history will not be actual)
or
2) Strore dependecy on Book object (In this case history will be actual, but in every request I must look at all dependencies)
I suppose that Books will be changed offen
And the History will be displayed in Person profile. (This assumption response will Answer 1) )
But should be history based on actual Book datas ? Or history should have the information form date where history was created ?
Book and Person are only examples
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定这里的“实际”实际上是什么意思,但更好的选择是适合您的需求的选择。
使用选项 1,当您稍后在个人资料中显示历史记录时,它将包含有关创建历史记录时当前图书的信息。使用选项 2,个人资料将显示查看个人资料时当前图书的信息。
您想在个人资料中看到哪些内容?
如果实际上您希望始终显示历史记录创建时的当前信息,这就是构建具有时间维度的数据仓库的原因之一。如果这是您所需要的,并且如果您需要处理大量历史数据,那么您可能需要考虑构建一个与事务数据库分开的数据仓库。
有关数据仓库的一些信息,这篇 IBM 红皮书文章可能有用。
Not sure what you actually mean by "actual" here, but the better choice is the one that suits your needs.
With option 1, when you later show the history record in your Person Profile, it will contain the information about the book which was current at the time the history record was created. With option 2, the profile will show the information about the book that is current at the time the profile is viewed.
Which do you want to see in the profile?
If in fact you want to always show information that was current at the time of the history record creation, this is one of the reasons for building a data warehouse with a time dimension. If this is what you need, and if it's something you need to do with alot of history data, you might want to look into building a data warehouse separate from your transactional database.
For some information on data warehouses, this IBM Redbook article might be useful.