python - Database Design for Covariance Matrix (constant size, diagonally symmetric) -
i'm new realm of relational database design, , trying store 9x9 covariance matrix in table. rows , columns x, y, z terms of position, velocity, , acceleration. so:
posx posy posz . . . accz ------------------------- posx | xx xy xz . . . posy | yx yy yz . . . posz | zx zy zz . . . . | . . . . | . . . . | . . . accz | so instance, upper-left element posxposx (shortened xx above), right posxposy, , on. matrix symmetric along diagonal (i.e. posxposy == posyposx). it's possible want store 6x6 matrix includes position , velocity in same table.
from research, i've found normalized table design of creating table fields row number, column number, , value (how represent 2-d data matrix in database). can see benefit flexibility, since number of rows , columns can variable. best way proceed, though have set number of rows , columns (9x9 and/or 6x6)? envision creating table has fields each unique row/col combination (posxposx, posxposy . . . etc). seems more intuitive me, said i'm new @ this.
my question is: how suggest representing data in relational database? i've outlined 2 possible methods don't know if either best way. "best" in case mean efficiently stored , retrieved. i'm creating data repository, data in database not changing once added, read numpy arrays or similar.
some more background:
i'm analyzing test data. have multiple test runs different configurations, each having multiple data points include lot of different kinds of data. 1 of data points want store , analyze covariance. amount of data i'm dealing quite staggering, i'm hoping using database me keep things organized , accessible. goal store data, , write data analysis , visualization tools draw data. in case of covariance, i'm calculating things mahalanobis distance, trace, , time propagated eigenvalues. have many of these tools already, pull lot of different log files , mess.
as long data-set small , can assume values once read not modified external application, might worth considering using csv file , read data whatever data structure useful while doing analysis. let @ data easier because need text editor or if wanted way view spreadsheet.
based on have said, seems cleanest thing have 1 record per cell because give flexibility in future. if interested in reading database design this pretty starting place
one possible design be:
table matrix(record_id, parent_id, matrix_id, x, y, value) where record_id uniquely identifies record, parent_id reference owning entity matrix, matrix_id uniquely identifies elements in matrix,x , y coordinates record , value cell value.
then query like:
select * matrix matrix_id=? order x asc, y asc
Comments
Post a Comment