Page 1 of 1

Web database design question

Posted: Thu Oct 17, 2002 6:40 pm
by chson

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.

Posted: Thu Oct 17, 2002 10:40 pm
by DoppyNL
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

Posted: Fri Oct 18, 2002 10:16 pm
by chson
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)