Re: multiple values, in a single column mysql
Posted: Fri Jan 27, 2012 1:24 am
Well, there are several ways to do that, the first is like you said, creating a coupling table where you bind race ID`s to the class ID`s, this is a logical step and follows the database normalisation standard, however you can also program this in your game itself. Verifying the selected race, and use an array in PHP to check which races to select from the database.
Anyway, the first is the best solution. Create a third table where you bind race ID`s to class IDs. It`s flexible. As far as stats go, you should do the same and normalise the database first. The class which you store in the db should be a boilerplate for the player. Let`s say a knight has a default strength of 10, the sum where the player starts with is 10 strength. Any and all future updates are player driven, so the player stats increase. This way you can also have stats for races, an orc ( logically and physically ) should be stronger then a human. So the base strength of an orc should be higher then the base strength of a human.
A player in your database should start with the base strength of the class and the race. You can be as specific as you want, add a new table where you can add extra modifiers and stats if a player reaches a new level, like increasing strength by 2 every new level, 1 for being human and 1 for being knight. But that`s something that`s not relevant, because that should be test-driven and balanced during playing and testing.
You could check out my database model for harry potter, i believe it has a same database model. Check my blog, it should contain 1 entry where the DB model is explained.
Anyway, the first is the best solution. Create a third table where you bind race ID`s to class IDs. It`s flexible. As far as stats go, you should do the same and normalise the database first. The class which you store in the db should be a boilerplate for the player. Let`s say a knight has a default strength of 10, the sum where the player starts with is 10 strength. Any and all future updates are player driven, so the player stats increase. This way you can also have stats for races, an orc ( logically and physically ) should be stronger then a human. So the base strength of an orc should be higher then the base strength of a human.
A player in your database should start with the base strength of the class and the race. You can be as specific as you want, add a new table where you can add extra modifiers and stats if a player reaches a new level, like increasing strength by 2 every new level, 1 for being human and 1 for being knight. But that`s something that`s not relevant, because that should be test-driven and balanced during playing and testing.
You could check out my database model for harry potter, i believe it has a same database model. Check my blog, it should contain 1 entry where the DB model is explained.