开发者

Database organization

This isn't much of a coding question as opposed to seeking help on 开发者_开发百科going down the right path. So, I have my users set up with username, password, email, posts, & id. The basic forum stuff. But, if I were to add more, say some games in the website that you play and store data with your forum account (being your account for the whole website, in other words), would it be wiser to add those fields to the existing table (i.e.: game1_money) or make another table for each individual side project, then create and link it to each user upon starting the "game" or whatever it is?

If I'm too vague, tell me and I'll try to clarify.


Use separate tables and then a left join when you want the data for the specific game or application. Then if 10% of the users are signed up for the game you don't waste the table space for the other 90%. You also don't need to keep fiddling with the user table.


Anonymous,

Always try to keep your primary table clean and relate everything back to a unique, individual index. In this case, whether you add games, comments, documents, whatever...user User_ID (for example) as the related index field that points back to your main users table.

Here's a good reference on building normalized tables http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html


Don't store that information in the Users table. Normalise into separate tables.

Create a separate table, say GameSavedInfo, to store this information and reference the users ID from the user table.

I would also create a GameDetails table and use its Id in the GameSavedInfo table.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜