- Joined
- Feb 14, 2003
- Location
- Southeast US
I'm coding a little web-based game with php. It's going to essentially be a strategy-type game, with harvesting resources and building up a military as the primary focus.
Anyway, the program will allow the player to have access to more than one type of race. Players default with humans, but as they play they may be able to entice up to 5 out of 10 additional races to join their estate.
And here is where I run into the relational question - I think I know the answer, but I'm no relational schema deity so affirmation would be great.
The simple way to account for this in the database would be add fields for every race (total pop) and what they're assigned to do. (woodcutters, goldminers, etc.)
But then I realized a better way would probably be to make a separate table called raceinfo, which would hold populations and assignments. a row might look like this:
userid, raceid, totalpop, woodworkers, goldminers... and so on.
This way the script, when generating the overview for the player, would hit up the raceinfo table and find that userid 1 has 500 of "raceid 3", or dwarves, and they are dispositioned "thusly".
Is that clear enough?
the first way, just cramming it all into the playerinfo table, would be easy but cumbersome at the same time (big queries) but the second way I think is more realistically true to the relational ideal.
Anyway, the program will allow the player to have access to more than one type of race. Players default with humans, but as they play they may be able to entice up to 5 out of 10 additional races to join their estate.
And here is where I run into the relational question - I think I know the answer, but I'm no relational schema deity so affirmation would be great.
The simple way to account for this in the database would be add fields for every race (total pop) and what they're assigned to do. (woodcutters, goldminers, etc.)
But then I realized a better way would probably be to make a separate table called raceinfo, which would hold populations and assignments. a row might look like this:
userid, raceid, totalpop, woodworkers, goldminers... and so on.
This way the script, when generating the overview for the player, would hit up the raceinfo table and find that userid 1 has 500 of "raceid 3", or dwarves, and they are dispositioned "thusly".
Is that clear enough?
the first way, just cramming it all into the playerinfo table, would be easy but cumbersome at the same time (big queries) but the second way I think is more realistically true to the relational ideal.