If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > relational db design

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-15-04, 13:18
Tyrnt Tyrnt is offline
Registered User
 
Join Date: Feb 2004
Posts: 1
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,

Tyrnt
Reply With Quote
  #2 (permalink)  
Old 02-15-04, 16:16
reneeb reneeb is offline
Registered User
 
Join Date: Jan 2004
Location: Germany
Posts: 167
I would suggest to use three tables to solve your problem:

first table:
name: monster
columns: monster_id
monster_name
primary key: monster_id

second table:
name: zones
columns: zone_id
zone_description
primary key: zone_id

third table (relation):
name: monster_zones
columns: monster_id
zone_id
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On