Results 1 to 2 of 2
  1. #1
    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 dont 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 Im pretty sure. I just am having trouble designing the tables.

    Thank you in advance,


  2. #2
    Join Date
    Jan 2004
    I would suggest to use three tables to solve your problem:

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

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

    third table (relation):
    name: monster_zones
    columns: monster_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. - The German Perl-Community

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts