skip to Main Content

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


  1. 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:

    damage matrix
    -------------
    hero1 
    hero2
    hero1dealt
    hero1received
    

    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.

    Login or Signup to reply.
  2. Just create a table with three columns like killer, victim and weight. The first row of the matrix would look like

    killer victim weight
    hero1_0 hero0_1 1
    hero1_0 hero0_3 6
    hero1_0 hero0_4 5
    hero1_0 hero0_5 1
    hero1_0 hero0_6 13
    hero0_2 hero1_0 1
    hero0_3 hero1_0 2
    hero0_4 hero1_0 2
    hero0_6 hero1_0 5

    The 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)-

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search