How to represent a 2-D data matrix in a database

后端 未结 6 1702
萌比男神i
萌比男神i 2020-12-07 11:38

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

Both the column names (A,B,C,D) and the Row names (1,2,3) are also importa

6条回答
  •  既然无缘
    2020-12-07 11:54

    This is one of the reasons why PostgreSQL supports arrays as a data type. See

    • http://www.postgresql.org/docs/8.4/static/functions-array.html and
    • http://www.postgresql.org/docs/8.4/static/arrays.html

    Where it shows you can use syntax like ARRAY[[1,2,3],[4,5,6],[7,8,9]] to define the values of a 3x3 matrix or val integer[3][3] to declare a column type to be a 3x3 matrix.

    Of course this is not at all standard SQL and is PostgreSQL specific. Other databases may have similar-but-slightly-different implementations.

提交回复
热议问题