两个不同的表还是一个带有布尔列的表? [英] Two different tables or just one with bool column?

查看:81
本文介绍了两个不同的表还是一个带有布尔列的表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有两个表:OriginalDocument和ProcessedDocument。在第一个文档中,我们放置了未经处理的原始文档。经过验证和处理(转换为我们的XML格式并进行了解析)后,将其放入ProcessedDocument表中。处理的文档可以是有效的或无效的。 哪个更有意义:对于有效和无效的文档,有两个不同的表,或者只有一个带有有效列的表?:某些列(〜5-7)与无效的文档无关。同时存储无效和有效文档也会使文档表中填充 NULL列(如果文档无效,则文件编号,接收者之类的信息可能是未知的)。

We have two tables: OriginalDocument and ProcessedDocument. In the first one we put an original, not processed document. After it's validated and processed (converted to our XML format and parsed), it's put into ProcessedDocument table. Processed document can be valid or invalid. Which makes more sense: have two different tables for valid and invalid documents or just have one with 'Valid' column? Some of the columns (~5-7) are irrelevant for invalid document. Storing both invalid and valid documents would also make Document table filled with 'NULL' columns (if document is invalid, information like document number, receiver can be unknown). What else should we consider and weigh, when making this decision?

推荐答案

文档有效还是无效,仍然是

Whether the document is valid or invalid, it is still a document so it makes inital sense for them all to be in the same table.

但是,如果无效文件被您的应用程序以不同的方式对待,直到几乎忘记(不查询,更新等)然后拆分表。将两种类型的文档放到同一张表中只会降低查询效率,没有直接好处。

However, if an invalid document is treated differently by your application to the point where it is almost forgotten (not queried, updated etc.) then split the tables. Having the two types of document together in the same table will do nothing but slow down your queries for no immediate benefit.

我有一个文档表,其中包含有效和无效的文档保持在一起,但这仅是因为该应用向用户重新展示了不良文档并要求他们修复它。

I have a document table where valid and invalid documents are kept together but only because the app re-presents the bad document to the user and asks them to fix it.

这篇关于两个不同的表还是一个带有布尔列的表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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