Thread: relational db design
02-15-04, 14:18 #1Registered User
- Join Date
- Feb 2004
Unanswered: relational db design
I am having trouble figuring how I can create tables to use for my website.
I'm creating a database for a game called World of Warcraft. There are monsters and NPC's and the like that can be in different areas, 'zones.' I need to have tables designed so I can have information about the different monsters and say which zone they are in but then they are able to click on the zone name and get information on that zone.
For example: a gnoll can be in 'the woods','grasslands', and 'forest'
but a grizzly bear is only in 'the woods'
How can I make it so that I don’t have to know how many zones a creature can be in, it is assumed it can be in as many as there are zones so I cant have a separate column for each zone or a preset amount of zones like 10 and have a id going to the zone it is in, that is a waste of space in the table because the majority of the monsters wont be in multiple zones probably.
I already know the PHP and mySQL part I’m pretty sure. I just am having trouble designing the tables.
Thank you in advance,
02-15-04, 17:16 #2Registered User
- Join Date
- Jan 2004
I would suggest to use three tables to solve your problem:
primary key: monster_id
primary key: zone_id
third table (relation):
primary_key: (monster_id, zone_id)
foreign_keys monster_id, zone_id
I think it's the most convenient solution...
In the relationstable you store the monsters and the zone where the monsters can be.board.perl-community.de - The German Perl-Community