MySQL efficiency questions
Posted: Mon Jan 04, 2010 8:23 pm
Ok, before I get too far into this game, I'm having doubts about how my player database tables are set up.
Currently I have a users table:
Then I have a charinfo table:
The userid in charinfo is the same id in users, to link the two together. These are stats that are present at character creation time, or derived from other permanent stats, so every player will have these.
I'm starting to add more skills to the game - some which all players have, and some which you have to train before you get (so not everyone will have them). Do I keep adding fields to charinfo to hold these? Or do I make a separate table for skills that not everyone will have and do something like this instead?:
Would I be better off combining 'users' and 'charinfo' and using simply use the third table for skills/stats that not everyone has? Or should I put all skills/stats in one table, no matter whether every character has them or not? Or does it really matter?
Currently I have a users table:
Code: Select all
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(30) NOT NULL,
`password` varchar(32) NOT NULL,
... other stuff clipped...
Code: Select all
`userid` int(11) NOT NULL,
`charid` smallint(2) NOT NULL,
`currlocation` int(11) NOT NULL,
`strength` smallint(3) NOT NULL,
`dexterity` smallint(3) NOT NULL,
`iq` smallint(3) NOT NULL,
`toughness` smallint(3) NOT NULL,
`charisma` smallint(3) NOT NULL,
`attack` int(5) NOT NULL,
`defense` int(5) NOT NULL,
`health` int(5) NOT NULL,
`fatigue` smallint(3) NOT NULL
I'm starting to add more skills to the game - some which all players have, and some which you have to train before you get (so not everyone will have them). Do I keep adding fields to charinfo to hold these? Or do I make a separate table for skills that not everyone will have and do something like this instead?:
Code: Select all
`userid` int(11) NOT NULL,
`skillname` varchar(30) NOT NULL,
`skillnum` smallint(3) NOT NULL