为什么RDBMS不支持列的数组类型? [英] Why don't RDBMS support array types for columns?

查看:163
本文介绍了为什么RDBMS不支持列的数组类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们看一个博客引擎的例子。

Lets take the beaten to death example of a blog engine.

你有博客,博客有帖子,帖子有标签用于组织目的。在决定标记问题在RDBMS环境中不是微不足道的情况下,我们转到google获取指导,并找到解决方案的以下整洁摘要作为第一个命中:设计相关基准。然而,所有这些都是以性能或复杂性为代价的。看起来像一个类似NoSQL的方法让你存储列中的标签列表(在NoSQL中我们可以存储文档中的文档)可以很好地解决这个问题。为什么不用SQLServer / Qracle / MySQL / Postgres / etc。有吗?

You have the blog, the blog has posts, the posts have tags for organizational purposes. After deciding that tagging problem is not trivial in an RDBMS environment, we go to google for guidance and find the following neat summary of the solutions as the first hit: designs and related benchmarks. However, all of them come at a cost of either performance or complexity. Seems like a NoSQL-like approach of letting you store a list of tags within a column (in NoSQL we can store documents in documents) would solve the problem nicely. Why don't SQLServer/Qracle/MySQL/Postgres/etc. have it then?

起初我以为这可能是因为不同的大小。但任何值得注意的RDBMS允许某种形式的varchar和文本(大小)。所以调整列的大小(和事实,不同行的同一列具有不同的大小不是问题)。因此,不是存储一个文本块,让我们在列中存储相同类型的项目(大多数语言的数组)的列表。让我们索引它为有效的精确搜索匹配。至少对于所有的使用情况,我有需要的NoSQL DBs将消失作为必要性(我知道很多人都在讨论可扩展性,但我不知道/足够了,我没有可扩展性问题,我有维修噩梦)。我们得到了简单的模式设计(每个位都像清洁和简单的文档NoSQL)和高效的索引性能。陌生人仍然,一个开源的数据库(例如Postgres)没有这种功能的某种补丁。开发人员在这些领域的动机似乎倾向于从头开始创建新的DBs。

At first I thought it might be because of the varying size. But any RDBMS worth noting allows some form of varchar and text (substantial in size). So sizing of the column (and the fact that the same column in different rows would have different size isn't the issue). So instead of storing a blob of text, let us store a list of items of the same type (an array in most languages) in a column. Let us index it for efficient exact searches matches. And at least for all use cases that I have the need for NoSQL DBs would disappear as a necessity (I know a lot of people are harping about scalability, but I don't know/care enough about that, I don't have scalability issue, I have maintenance nightmares). We get simplistic design of our schema (every bit as clean and simple as document in document of NoSQL) and great performance thanks to efficient indexing. Stranger still, that an open source DBs (e.g. Postgres) don't have some sort of patch for this feature. Developers with motivation in the fields seem way to enamored with creating new DBs from scratch, these days.

我缺少一些令人吃惊的技术障碍,或者上述RDBMS供应商只是懒惰

Am I missing some staggering technical obstacle or are the aforementioned RDBMS vendors just lazy or leaving in the past?


推荐答案

>允许表中单元格内的任何集合类型的值通常被视为违反1NF,因为它暗示按定义在(表的一行)内出现重复组的可能性。

Allowing values of any "collection" type inside a cell in a table, was typically considered a violation of 1NF, as it implied, "by definition", the possibility of "repeating groups" appearing inside a (single row of a) table.

但是,从早期的SQL开始,Theory已经发展了很多,而且理论目前有这样的:

Theory has evolved quite a bit since the early days of SQL, however, and theory currently has it that :

(a)在单元格中应该允许任何类型的值,包括数组/集合/集合类型。
(b)要在1NF中,只是指关系数据。 (但请注意,SQL表通常是关系数据,在某种意义上如何定义概念。)

(a) Any type of value, including Array/Set/Collection types, should be allowed in a cell (b) To be in 1NF, simply means to be relational data. (But note that SQL tables typically are NOT "relational" data in the sense how theory defines the concept.)

日期写了几十个页面。阅读你的方式通过这些将为您提供一个答案,你的问题是比任何答案,在这里更完整。

Date has written dozens of pages on the subject. Reading your way through those will provide you with an answer to your question that is far more complete than any answer that can fit in here.

这篇关于为什么RDBMS不支持列的数组类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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