My question is about tabulating data in MySql. I was wondering, how to best represent this javascript array in MySql? What index should I use? I’m going to use the data to populate a javascript array via PHP.
A[i] represents a card. B[i] represents a matching card.
A = new Array();
A[0] = new Array();
A[0][0]='eat';
A[0][1] = 1;
A[0][2] = 0;
A[1] = new Array();
A[1][0]='drink';
A[1][1] = 2;
A[1][2] = 0;
B = new Array();
B[0] = new Array();
B[0][0]='tacos';
B[0][1] = 1;
B[0][2] = 0;
B[1] = new Array();
B[1][0]='tequila';
B[1][1] = 2;
B[1][2] = 0;
I need to be able to uniquely identify components within the array later, so that I can use parts of the data to populate new arrays (So I can use and combine different cards into a new array). For example, I might want to populate a new array in javascript using A[0][0], A[0][1], A[0][2],B[0][0], B[0][1] and info from another array stored in the MySql (Lets say Y[2][0], Y[2][1],Y[2][2],Z[2][0], Z[2][1]).
This is what I’ve come up with so far.
-----------------------------------------
| card pair | card |card info|Tag|Tag2|
-----------------------------------------
| 1 | A | eat | 1 | 0 |
| 1 | B | tacos | 1 | - |
| 2 | A | drink | 2 | 0 |
| 2 | B | tequila | 2 | - |
-----------------------------------------
Maybe I need to add a primary index to the above one?
-------------------------------
|card pair |card info|Tag|Tag2|
-------------------------------
| 1A | eat | 1 | 0 |
| 1B | tacos | 1 | - |
| 2A | drink | 2 | 0 |
| 2B | tequila | 2 | - |
-------------------------------
I thought the card pair could be the index. Not sure if this is possible or a good idea. Also not sure what type of index I would use if I did.
If you have a better way to tabulate the data or can recommend what type of index to use I’d much appreciate it.
EDIT: I think I can do away with the last 2 columns (Tag and Tag2), so I think I might just use the table as below.
----------------------
|card pair |card info|
----------------------
| 1A | eat |
| 1B | tacos |
| 2A | drink |
| 2B | tequila |
----------------------
Should I add an incrementing index to the table? Is the card pair sufficient as the index?If yes, what is the best index type to use?
Thanks!
well, from a database perspective, you will want to ‘normalize’ this information.
I think it would be more like this: