两个不同的表还是一个带有布尔列的表?

编程入门 行业动态 更新时间:2024-10-28 00:18:52
本文介绍了两个不同的表还是一个带有布尔列的表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我们有两个表: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.

更多推荐

两个不同的表还是一个带有布尔列的表?

本文发布于:2023-10-27 18:22:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1534167.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:布尔   两个

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!