如何在数据库中表示二维数据矩阵 [英] How to represent a 2-D data matrix in a database

查看:22
本文介绍了如何在数据库中表示二维数据矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据集,它由一个 ID 和一个与该 ID 相关的数据矩阵 (n x n) 组成.

I have a data set which consists of an ID and a matrix (n x n) of data related to that ID.

列名 (A,B,C,D) 和行名 (1,2,3) 也很重要,需要为每个单独的 ID 以及数据 (a1,b1,c1,d1,...)

Both the column names (A,B,C,D) and the Row names (1,2,3) are also important and need to be held for each individual ID, as well as the data (a1,b1,c1,d1,...)

例如:

我正在尝试确定在数据库中对该数据集进行建模的最佳方式,但是,鉴于 RDBMS 的扁平性质,这似乎有些困难.

I am trying to determine the best way of modelling this data set in a database, however, it seems like something that is difficult given the flat nature of RDBMS.

我是最好持有 ID 和一个表示数据矩阵的 XML blob,还是我在这里忽略了一个更简单的解决方案.

Am I better off holding the ID and an XML blob representing the data matrix, or am i overlooking a simpler solution here.

谢谢.

推荐答案

RDBMS 不是扁平的.R 部分负责这一点.您需要的是:

RDBMSes aren't flat. The R part sees to that. What you need is:

Table Entity
------------
ID

Table EntityData
----------------
EntityID
MatrixRow (1, 2, 3...)
MatrixColumn (A, B, C, D...)
Value

Entity:EntityData 是一对多的关系;矩阵中的每个单元格都有一个 EntityData 行.

Entity:EntityData is a one-to-many relationship; each cell in the matrix has an EntityData row.

现在您拥有了一个可以在 SQL 级别进行分析的架构,而不仅仅是一个数据转储,您必须在应用程序级别提取和提取所有内容才能找到有关它的任何信息.

Now you have a schema that can be analyzed at the SQL level, instead of just being a data dump where you have to pull and extract everything at the application level in order to find out anything about it.

这篇关于如何在数据库中表示二维数据矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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