实现数据库中的审阅标志;最佳做法 [英] Implementing Review flags in Databases; best practices

查看:233
本文介绍了实现数据库中的审阅标志;最佳做法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要存储一些与某些实体相关的审核标志。每个审阅标志只能与单个实体属性组相关。例如表 Parents ParentsStatus 标志和表有一组 ChildrenStatus 标志。

I need store some review flags that relate to some entities. Each review flag can only related to a single entity property group. For example table Parents has a ParentsStatus flag and table Children has a set of ChildrenStatus flags.

在目前的设计建议中,我有三个表格:

In the current design proposal I have three tables:

  • ReviewTypes: stores the flags and the properties they relate to.
  • ReviewPositions: stores the values the flags can have.
  • Reviews: stores the transaction data, the actual reviews. It is like UsersToFlags: Flags in a database rows, best practices.

问题是我被推回,没有必要有 $ c>表,最好只是将这个实际的审核数据存储在每个实体上。例如,向 Parents 添加一个额外的列,以保存 ParentsStatus 。他们觉得这是一个更简单的解决方案,将数据分离出来只是过度的情况。

The problem is I am getting push back that there is no need to have the Reviews table and it would be better to just store this actual review data on each entity. For example add an extra column to Parents to hold ParentsStatus. They feel it is a simpler solution and separating the data out is just "overkill" for out scenario.

我不喜欢这个想法,因为这意味着每次我们想要添加一个新的审查标志,我们需要更新核心实体表来保存那个标志。

I don’t like this idea as this means that every time we want to add a new review flag we need to update the core entity table to hold that flag.

空间不是问题。

人们有什么强烈的意见吗?

Do people have any strong opinions?

编辑:

此评论适用于三个答案。共识是关系方法是最好的,但我想我需要阅读一点EAV模型,从一些非常基本的阅读用于理解EAV数据库模型的最佳初学者资源?及其相关链接看起来并不是非常简单,我不想挖掘自己一个洞。感谢wildplasser。我会再读一读后回来。

This comment applies to the three answers. The consensus is the relational approach is best but I think I need to read up a little more on the EAV model as from some very basic reading Best beginner resources for understanding the EAV database model? and its related links it does not appear to be super straightforward and I don't want to dig myself a hole. Thanks to wildplasser. I'll loop back once I read up a bit more.

推荐答案

哦,是的。他们的想法更简单,直到你想要增强它。给定的计划,他们提出如果每个实体需要两次审查。如果你想附加其他的东西,如笔记/注释。一旦他们发现他们的想法是一个充气飞镖的多少,你必须移动到更有用的一个?更不用说你需要一些方法来识别状态字段,使用脆弱的垃圾,例如列名以_Status结尾,或者你必须在某处硬编码。

Oh yes. Their idea is simpler, until you want to enhance it. Given the scheme they are proposing what if two reviews were need per entity. What if you wanted to attach other things such as notes/annotations. Once they find out how much of an inflatable dartboard their idea is, what do you have to move to a more useful one? Not to mention you need some way of identifying status fields, with fragile rubbish like Column name ends with "_Status", or you have to hard code them somewhere.

适当地不是那么多的工作,它不是更复杂,事实上在许多方面它更简单,它将以远远更低的成本应付无形的变化。

Doing it properly is not that much more work, it's not more complex, in fact in many ways it's simpler and it will cope with the invetible changes at far less cost.

这篇关于实现数据库中的审阅标志;最佳做法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆