从字面上保存多个模型状态的快照
我对编程相当陌生,我正在 Rails 中为分析实验室开发一个簿记应用程序。记录维护事件时,从字面上保存关联模型中某些数据的快照会很有用。换句话说,我们有仪器、仪器的测试方法以及在仪器上执行的维护事件,但方法是可变的,因此在执行维护时最好有一个方法状态的静态记录。
简单地创建一个单独的快照/状态模型来仅存储来自关联模型的数据,这是好的数据库设计吗?这对我来说是有道理的,但我对编程还很陌生,所以要警惕养成坏习惯。谢谢!
I'm fairly new to programming, and I'm developing a bookkeeping app in Rails for an analytical lab. When logging maintenance events, it would be useful to save a snapshot of certain data from associated models literally. In other words we have instruments, testing methodologies for the instruments, and maintenance events performed on the instruments, but methodologies are changeable, so it would be nice to have a static record of the state of the methodology when a maintenance is performed.
Is it good database design to simply create a separate snapshot/state model that just stores the data from the associated models literally? This makes sense to me but I'm new enough to programming to be wary of forming bad habits. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想您有模型
Instrument
、Methodology
和MaintenanceEvent
。我将简单地为每个维护事件分配已使用的方法:然后您将能够访问在特定仪器上的维护事件期间使用的方法。例如,要了解显微镜在上次维护期间使用了什么方法:
I suppose you have the models
Instrument
,Methodology
andMaintenanceEvent
. I would simply assign to each maintenance event the methodology that has been used:Then you'll be able to access the methodology used during a maintenance event on a certain instrument. For example, to know what methodology has been used on a microscope during its last maintenance: