Web database design question

Codes here !

Moderators: macek, egami, gesf

chson
New php-forum User
New php-forum User
Posts: 8
Joined: Mon Oct 14, 2002 5:57 pm

Web database design question

Postby chson » Thu Oct 17, 2002 6:40 pm

Hi.

I'm creating a text based fighting game simulator that'll have people saving their characters on mySQL. How should I design my table(s) to store each characters fighting history?

For example:

John has wins against Eric, Joe, Peter, Kenny, and Chuck.
Joe has wins against Eric and Peter. Losses against Kenny and Chuck.

How would I design a database for this? I'm thinking the only way to do this is by creating a seperate table for each fighter. This is probably too broad of a question to ask but I'd appreciate any kind of input.

DoppyNL

Postby DoppyNL » Thu Oct 17, 2002 10:40 pm

You need only 2 tables for this:
table 1 (users): userID, username, other_info
table 2 (battles): winner(refers to "userID" in "users"), loser (refers to "userID" in "users"), other_info

Greetz Daan

chson
New php-forum User
New php-forum User
Posts: 8
Joined: Mon Oct 14, 2002 5:57 pm

Postby chson » Fri Oct 18, 2002 10:16 pm

Thanks DoppyNL.

After I posted this question I figured out a solution that was somewhat similar to yours.

create table history
( Date date,
Winner char(25),
Loser char(25)
);


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 2 guests