How should I setup my mySQL tables for this simple

2019-07-29 09:21发布

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!

0条回答
登录 后发表回答