Sign in to follow this  
Beemer

mysql

Recommended Posts

Heyas; I'm a guy that is just getting into game development. I have a ton to learn yet, and I have been doing it all on the fly. With that said, let me get to the reason of my post. Currently, I am having trouble in the building of my database, so I thought I'd throw the problem to some of you, in the hopes that someone can make a suggestion that would work. I'm currently working ona sci-fi multiplayer, turn-based strategy game that deals with the 'mecha' genre. If the game does well, I hope to expand upon it, making it an MMO, and introducing empire management, and other cool things. Anyhow, I'm using mysql as the database in which to store all the relevant information for my mechs, but am having trouble. You see, each mech consists of several sections; head, L/R arm, L/R torso, center torso, L/R leg, as well as R/L rear torso, and center rear torso. Each section has an assignment of armor points & internal points. Also, weapons are location specific, so that when a mech loses an arm, the weapons in the arm are also lost. With that foundation established, the problem I am having is getting away from creating duplicate entries, as duplicate entries would quickly make the database grow too quickly. The primary key that I'm using is a code specific to each mech - a 'mech code'. So far, I have the following tables that are relevant building blocks of a mech; weapon table - a list of weapons, their ranges, their damages, etc. mech_armor - armor & internal per section of the mech mech_eq - equipment of the mech, i.e. gyro's, actuators, sensors, ecm, & etc. In the above tables, there weren't any problems in duplicate entries, as each section so far has had one value associated to each section of the mech. The problem begins when I try to assign multiple weapons to each mech section. For example, if i want to add 2 lasers to the left torso. Any way I create this table, I get duplicate entries. As some of you may have guessed, I am just learning MySQL, and I am convinced that there is an easy solution to this problem. Anyone willing to give me a push in the right direction?

Share this post


Link to post
Share on other sites
It might be easier to incorporate a count of weapons per body section rather than try to implement this via indexing. To define something like this via indexing seems overly complex - but then I'm not a database expert. Sorry. Perhaps a current weapon inventory table like this:

mechCode  bodyPartCode  weaponCode weaponCount


Edit: btw. I believe this is called a join table. It's the way you describe or define the relationships between the base tables you have - ie. a mech consists of these parts, or a mech has these weapons on these body parts. This way, when you want to show something like the mech loses an arm and therefore the weapons associated with it, you simply remove the relevant row from the appropriate join table(s).

hth
F451

[Edited by - Fahrenheit451 on October 22, 2005 9:54:56 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this