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

后端 未结 6 1711
萌比男神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:56

    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 is a one-to-many relationship; each cell in the matrix has an EntityData row.

    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.

提交回复
热议问题