How to model tabular data

Hi Everyone,

I have a requirement where I think a tabular data setup would be
noice. I’m changing from a very well established paper
system. Before I get into it I’ll exapnd on the requirement.

I need to rate items according to a matrix. eg

x1 x2
x3 x4
y1 v1 v1 v2 v2
y2 v1 v2 v2 v3
y3 v2
v2 v3 v3

This matrix needs to be defined by the client and then stored in the
db. The matrix will always be rather small. I don’t expect
even near 10 x 10.

The x’s, y’s, a v’s are all AR models with X, Y and V classes respectively.

The X and Y objects are effectivley labels. I want to be able to ask the matrix for the value given x and y.

The X and Y objects belong only to this matrix but the v’s can exist in any matrix.

I’m really at a loss for how to implement this efficiently.

So far I’m thinking that a model that holds everything is a must. Say MyTableMatrix
I’m also thinking at this stage that classes X and Y should
acts_as_list :scope => matrix_id so that I can maintian the column
and row order

I’m also thinking that, in order to be able to keep the data organised
when changing row and columns around is to keep the object identifier (
x, y) in with the data. I’m not completely sold on this idea
though.

Really though I have no idea how to implement this. Anyone care to give me some pointers, or maybe a link?

Cheers
Daniel