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
This is one of the reasons why PostgreSQL supports arrays as a data type. See
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.