在数据库中实现Review标志;最佳做法

时间:2023-01-19 20:07:01

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.

我需要存储一些与某些实体相关的评论标记。每个审阅标志只能与单个实体属性组相关。例如,表格Parent有一个ParentsStatus标志和表格Child有一组ChildrenStatus标志。

In the current design proposal I have three tables:

在目前的设计方案中,我有三个表:

  • ReviewTypes: stores the flags and the properties they relate to.
  • ReviewTypes:存储标志及其相关的属性。
  • ReviewPositions: stores the values the flags can have.
  • ReviewPositions:存储标志可以具有的值。
  • Reviews: stores the transaction data, the actual reviews. It is like UsersToFlags: Flags in a database rows, best practices.
  • 评论:存储交易数据,实际评论。它就像UsersToFlags:数据库行中的标志,最佳实践。

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.

问题是我得到了回击,没有必要有评论表,最好只是将这些实际的评论数据存储在每个实体上。例如,向Parent添加一个额外的列以保存ParentsStatus。他们认为这是一个更简单的解决方案,将数据分离出来只是对于场景而言“过度杀伤”。

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.

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

Space is not a problem.

空间不是问题。

Do people have any strong opinions?

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

Edit:

编辑:

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.

此评论适用于三个答案。共识是关系方法是最好的但我认为我需要阅读更多关于EAV模型的内容,从一些非常基本的阅读最佳初学者资源来理解EAV数据库模型?它的相关链接看起来并不是那么简单,我不想给自己挖一个漏洞。感谢wildplasser。一旦我读了一点,我就会回来。

3 个解决方案

#1


3  

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.

哦,是的。他们的想法更简单,直到你想要增强它。鉴于该计划,他们提议如果每个实体需要两次审核。如果您想附加其他内容(如注释/注释),该怎么办?一旦他们发现了他们的想法是多少的充气飞镖,你有什么需要转向更有用的?更不用说你需要某种方法来识别状态字段,像列名这样的脆弱垃圾以“_Status”结尾,或者你必须在某处硬编码。

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.

正确地做到这一点并不是更多的工作,它并不复杂,事实上在很多方面它更简单,它将以更低的成本应对不可改变的变化。

#2


2  

normalization is always preferable to premature optimization.

归一化总是优于过早优化。

#3


1  

One reason why I like the reviews table separate is that you can hold changes you may not want to display yet (as it hasn't been reviewed and approved) and still maintain the old dat until the new is approved. I don't know if your situation requires that.

我将评论表分开的一个原因是您可以保留您可能不想显示的更改(因为它尚未经过审核和批准),并且在新的批准之前仍然保留旧的数据。我不知道你的情况是否需要。

To make future programming simpler for when you want to display the changes, you can write a view that shows the old and new data.

为了使您希望显示更改时未来的编程更简单,您可以编写一个显示旧数据和新数据的视图。

#1


3  

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.

哦,是的。他们的想法更简单,直到你想要增强它。鉴于该计划,他们提议如果每个实体需要两次审核。如果您想附加其他内容(如注释/注释),该怎么办?一旦他们发现了他们的想法是多少的充气飞镖,你有什么需要转向更有用的?更不用说你需要某种方法来识别状态字段,像列名这样的脆弱垃圾以“_Status”结尾,或者你必须在某处硬编码。

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.

正确地做到这一点并不是更多的工作,它并不复杂,事实上在很多方面它更简单,它将以更低的成本应对不可改变的变化。

#2


2  

normalization is always preferable to premature optimization.

归一化总是优于过早优化。

#3


1  

One reason why I like the reviews table separate is that you can hold changes you may not want to display yet (as it hasn't been reviewed and approved) and still maintain the old dat until the new is approved. I don't know if your situation requires that.

我将评论表分开的一个原因是您可以保留您可能不想显示的更改(因为它尚未经过审核和批准),并且在新的批准之前仍然保留旧的数据。我不知道你的情况是否需要。

To make future programming simpler for when you want to display the changes, you can write a view that shows the old and new data.

为了使您希望显示更改时未来的编程更简单,您可以编写一个显示旧数据和新数据的视图。