二维矩阵代数数据库设计
任何人都可以就用于存储 2D 时间序列矩阵数据的数据库设计/DBMS 提供建议。允许快速后端代数计算:例如:
表 A、B、C.. Col1:日期-时间戳 col2:数据数组? (矩阵数据)
- SQL 伪代码
INSERT INTO TABLE C 选择 将 A.Data A 乘以 B.Data 其中矩阵 A 开始日期 = 矩阵 B 开始日期 矩阵 A 结束日期 = 矩阵 B 结束日期
本质上是设置计算的坐标。
Can anyone advise on a database design/DBMS for storing 2D Time Series Matrix data. To allow for quick BACK END algebraic calculations: e.g:
Table A,B,C..
Col1: Date- Timestamp
col2: Data- Array? (Matrix Data)
- SQL Psuedo Code
INSERT INTO TABLE C
SELECT
Multiply A.Data A by B.Data
Where Matrix A Start Date = Matrix B Start Date
And Matrix A End Date = Matrix B End Date
Essentially set the co-ordinates for the calculation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
矩阵代数的困难在于确定用于数据建模的矩阵上的域是什么。它是一个值吗?整体是一个矩阵吗?这不是一个预先定义的问题,所以我会给你两个解决方案以及权衡是什么。
解决方案 1:矩阵单元中的值是一个域:
最大的问题是这不能很好地强制矩阵大小。此外,缺失值可用于表示 0,或者可能不允许。使用矩阵作为一个整体作为域的想法具有一定的吸引力。在这种情况下:
请注意,包括 PostgreSQL 在内的许多数据库都会强制数组实际上是一个矩阵。然后你需要编写自己的乘法函数等。我建议在 PostgreSQL 上以对象关系方式执行此操作,因为它对于此类事情非常可编程。类似于:
然后您可以将矩阵乘法称为:
您甚至可以将其他两个矩阵的乘积插入到表中:
The difficulty with matrix algebra is determining what is a domain on the matrix for data modelling purposes. Is it a value? Is it a matrix as a whole? This is not a pre-defined question, so I will give you two solutions and what the tradeoffs are.
Solution 1: Value in a matrix cell is a domain:
The big concern is that this does not enforce matrix sizes very well. Additionally a missing value could be used to represent 0, or might not be allowed. The idea of using a matrix as a whole as a domain has some attractiveness. In this case:
Note that many db's including PostgreSQL will enforce that an array is actually a matrix. Then you'd need to write your own functions for multiplication etc. I would recommend doing this in an object-relational way and on PostgreSQL since it is quite programmable for this sort of thing. Something like:
Then you can call the matrix multiplication as:
You could even insert into the table the product of two other matrices: