数据库设计:我们是否应该为映射表添加时间戳列?
通常,它约定不更新映射表的记录,而是删除相同的记录并添加新的记录。
在这种情况下,在映射表中添加 Updated_on 列并不相关,但仍然有人可能会错误地或故意更新表,这表明在所有表中都添加了 Updated_on 列。在所有表中添加created_on列似乎很合乎逻辑,但有点令人困惑。请建议?
什么是约定?
Usually it convention not update records of mapping tables rather delete same and add new.
In that case it is not relevant to add updated_on column in mapping tables but still some one can update the table by mistake or intentionally which suggest to have updated_on column in all tables. It seems quite logical to add created_on column in all of tables, but confuesd little bit. Please suggest?
what is convention ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为除非您打算使用这些信息,否则您不应该这样做。否则,您必须有触发器来保持数据最新,否则您会简单地忘记,并且行数据将毫无意义。此类触发器会对性能产生不同的影响(在 PostgreSQL 上,影响应该非常小,在其他一些触发器上可能影响较小)。
一般来说,没有什么比用无意义的数据填充数据库更糟糕的了(因为它没有正确更新)。您应该尽可能避免这种情况。
I think that you should not do this unless you plan to use the information. Otherwise you have to have triggers that will keep the data up to date, or you will simply forget and the row data will be meaningless. Such triggers will have different implications performance-wise (on PostgreSQL the impact should be pretty minimal, on some others perhaps less so).
In general there is little worse than filling your database with meaningless data (because it wasn't properly updated appropriately). You should avoid this to the extent possible.