Closed jaicab closed 8 years ago
David, can you please break down the DB and move it to text instead of an image and put it at the top? Bear in mind that we need to add vitamins. Also explain what each table and field represents.
Sure ! About vitamins, they are displayed on the screen in the same way that hordes, so we save only the data about vitamins on the second table (records)
Ok, you just need to create a list for each table in markdown to replace the image. That way we can all edit it and we have it there, centralised.
Ok, I'm proposing a few changes. Let me know what you think.
user
table (id
, email
) and then a id_user
reference on the training table. This would allow us to change the fields on user without affecting the SQLs in training and vice versa. It's basically more scalable.version
field to gen
or generation
across tables. We may end up using version to refer to the version of the calculator. I would also recommend using numeric IDs for this field and not xy/oras as it would be easier to scale.stat_name
field to see what stat this operation refers to and a value
field which can be positive or negative. We also need a id_horde
field and a id_vitamin
field to know if they used any of those.times_used
as we can extract that counting from the records table. They should have a value
field that represents how much add to their stat. We don't really need these tables at all, they could be just in the PHP, but it's worth discussing if they change what's easier to edit.I think this way we not only avoid redundancy, but also improve scalability and our possible studies on the results.
Ok. let's do it point by point:
version
field to gen
or generation
across tables : generation
is not the proper word. We are going to use game
instead because in general generation
includes a group of games. For example, this calculator is working with all the VI 'gen' pokemon games.id_horde
and an id_vitamin
then it means that the data is saved in any other table, isn't ? If not, there is something that I don't understand. I don't know about vitamins, but hordes may change in the future with the release of the new games. Anyway, we should discuss this issue in person.I'm updating the tables above with the new changes.
I like the use of game
instead of generation
. Nice one.
Regarding the id_horde
and id_vitamin
, these go on the records
table. We can have a static list in PHP or JSON (or both) that lists the hordes and vitamins. What I mean by static is that there are rarely to change, not like records and training which would constantly change. There is no need to have them in a DB because we never are going to change them with a form request or a SQL, and it's us the dev team that is going to change the data in that table.
My point is that when something is internal and it's not going to change or it's unlikely it's going to change often, it should be plain in the code and not in a DB. So, for instance we could have:
$hordes = array();
// These could be abstracted into a function
$horde_magikarp = new stdClass();
$horde_magicarp->name = "Magikarp";
$horde_magikarp->game = 'xy';
array_push($hordes, $horde_magikarp);
// Now we can just use it
echo $hordes[0]->name; // "Magikarp"
// Get the ones for the game 'xy'
function filterByGameXY($var){
return $var->game === 'xy';
}
// Now $hordes_xy only contain the hordes that are assigned to XY trainings
$hordes_xy = array_filter($hordes, 'filterByGameXY');
All this loads much faster than getting to the DB and doing stuff.
Got it !! Nice explication !! You'r making magikarp useful for once in life !!
Glad you got the idea. I also think it should be a JSON file with the hordes and another with the vitamins, and then we process that with PHP so it's easily available. I say JSON because we can cache it and it would be instantaneous, but giving us the flexibility to do other stuff.
Also, if we feel like it, we can always move the data from the JSON file to tables in the DB and then create the JSON from it. Super scalable!
I've added timestamp
to the user
table.
Thanks ! :D
Training: Training table saves all the data for a single training session.
Records: Records will provide us with information about how users are using the application, which version of the game is the most used and more
User: First approach of the User basic table. Not used in the first version.
Please check the new database diagram, make and comment any change that you consider relevant ASAP because I'm going to install and test the DB in the server tomorrow in the morning.
Thanks.