Many to many relation ship
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Many to many relation ship

  1. #1
    Join Date
    Jul 2002
    Posts
    29
    Hi all,

    When we r designing the database if we get the situation like many to many relation ship what do we do.

    Please give me the answer as soon as possible.


    Cheers.

  2. #2
    Join Date
    Jan 2002
    Posts
    57
    You would add another table to handle the many-many mappings.

    Suppose we have 2 table: fish and fish_food

    Fish:
    ID NAME
    1 trout
    2 bass

    Fish_Food:
    ID NAME
    1 worms
    2 minnows
    3 bugs
    4 frogs

    A new table, fish_food_mapping, could be created to relate fish and fish_food

    Fish_Food_Mapping:
    Fish_ID Fish_Food_ID
    1 1
    1 2
    1 3
    2 2
    2 4

    Don't forget about PK and FKs in the mapping table.

    --
    Paul

Posting Permissions

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


Click Here to Expand Forum to Full Width