问题
Hello I am trying to figure out the best way to setup my two mysql tables for a simple points system?
What I have:
1 - users table with id (unique),name,email,etc
1 - points table with id (auto incrementing),user_id (corresponds with id field in user table), points
Currently I am just writing to the points table and letting the id field auto increment... and setting the user_id field and points fields with php in the query.
Is this the "proper" way to set this up? Where the id from the user table is common with the user_id field in the points table? Or is there a better way?
I feel like maybe I should just have two fields in my points table (id,points) and then have the id's correspond? Just not sure what's best? What I should be doing here?
I just want to be able to have a function or two that let me update the points field for a user... or read it... etc?
Thanks for helping!
来源:https://stackoverflow.com/questions/14847202/how-should-i-setup-my-mysql-tables-for-this-simple-php-points-system