views:

76

answers:

1

I am trying to best figure out a way to store this particular case of data in a static database table

on the front end the user will be presented with a simple table (say 5x5 by default) but the user can expand or delete rows/ columns at will.

The idea is that the first column will be labels that are the same as the headers, similar to a graph and that any change to either is reflected to the other, so the graph (not really a graph, but I feel it is a valid comparison) remains a square

     col1    col2    col3    col4    col5
row1   1      5       6        8      9

row2   2      3       4        5      3

row3   0      0       0        0      0    all values can be different

row4   0      0       0        0      0    the row and column names will be the same always

row5   0      0       0        0      0

IE (start with 5x5, if user removes row5 or col5 it becomes 4x4)

so because of this dynamic amount of columns I am unsure how to represent it in a table in the database.

each cell in the "map" will just contain an int and I am having a hard time finding an elegant way to map this in my database for usage with linq to sql

any ideas?

EDIT: I could simply wrap everything from the front end in a JSON object and have a bunch of code for that but i'm not sure if that would be easiest or not, mainly looking for some good input for now

+1  A: 

Here's a start, using a Graph table with separate tables for columns, rows and cells. It' doesn't enforce the "squareness" of the graph, but you could enforce that in your application logic.

Graph
- GraphID

GraphColumn
- GraphID
- ColumnID
- ColumnName

GraphRow
- GraphID
- RowID
- RowName

GraphCell
- ColumnID
- RowID
- CellValue
Eric Petroelje