Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Posts
    1

    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,

    Tyrnt

  2. #2
    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

Posting Permissions

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