I have the following problem. I need create tables for storing data like adjacency matrix. For example the images below:
kills relationship between heroes
Damage relationship between heroes
I need to store this relationship between the heroes.
I have the following problem. I need create tables for storing data like adjacency matrix. For example the images below:
kills relationship between heroes
Damage relationship between heroes
I need to store this relationship between the heroes.
2
Answers
If you know there will be no changes to the number of rows you could store this where each row of the matrix is a row in the table.
But this is a bad idea. Instead you want a table where each row represents all the data about a cell in the table.
In your example image you show what any of these things are so it is hard to write out all the details here.
But probable something like this:
Remember in a table like this the values are repeated twice but swapped. In one cell the you show the dealt and received values for hero1 and in another you show the dealt and received values for hero2
You only need to store these values from the point of view of one hero and then swap them for the other.
I’m assuming this table is only damage dealt and received between the two heros — if it has total damage then you would need 4 columns of course.
Just create a table with three columns like
killer
,victim
andweight
. The first row of the matrix would look likeThe heroes in this example are denoted in the form heroROW_COLUMN (ROW 0 ist the matrix row header and COLUMN 0 is the column header, respectively)-