As posted in a previous thread, I'm attempting to make a turn-based game playable in a browser, by which players receive X amount of turns per hour to accomplish whatever tasks they would like to do.

I'm a fairly decent programmer, but database structure in MySQL is something that I am quite new to. The way the game is set up, each user account is a character in the game. My question is, should I make one table that is used to handle all of the user/character information, or should I make two tables and link them together in someway.

For example, basic user information will be fields such as, id, password, email, salt, etc. Character information is more related to gameplay, and contains information such as strength, agility, turns remaining, health, etc.

Should one table contain all of this information for each user/character? Or should I create two separate ones and link them with a common id #?

    The proper way to think about this is to create a table for each 'entity'. The entities may have relationships -- the relationships are also described with tables.

    For example, baseball.
    You might have a 'person' table. Name, DOB, etc.
    And a 'team' table: location, owner, etc.
    And team-person table: Team id, person id, date started on team, date ended.

    ETC. Etc.

    The key is DON'T duplicate data.
    DON'T put the the names and dates of every player in some sort of giant TEAM table. Separate the entities.

      great advice nemonoman. learning to do things this way really sped things up for me. Only thing I would add is the importance of sketching an outline ahead of time, especially for something as potentially complicated as a game database. I believe there are also programs out there that will map databases visually for you if you start getting confused by different relationships.

        Write a Reply...