Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matrices and databases

Tags:

database

I went through the topic and found out this link quite useful and simple at the same time. Storing matrices in a relational database But can you please let me know if the way mentioned as

A B C D
E F G H
I J K L

[A B C D E F G H I J K L]

is the best and simple or even reliable way of storing the matrix elements in the database. Moreover I need to multiply two matrices and make the operation dynamic. So will the storage of data this create any problems for the task?

like image 620
Sachindra Avatar asked Feb 06 '10 11:02

Sachindra


1 Answers

In postgresql you can actually have multidimensional arrays, define your own types and define your own functions on those types. For instance one could simply do:

CREATE TABLE tictactoe (
    squares   integer[3][3]
);

See The PostgreSQL manual for info on how to create your own types.

like image 152
wich Avatar answered Oct 11 '22 17:10

wich