Results 1 to 3 of 3

Thread: Database Structure

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Posts
    98

    Database Structure

    Im trying to build a database to organize comics.

    I want to track the Appearance of other characters.

    So.

    One comic can have many different Guest Appearences. Thats a 1 to many.

    A character can be a guest in many comics. That is also a 1 to many.

    So I have a many 2 many relationship. That is not good.

    What can I do to break this up? Create 2 tables. One to track the guest appearances and another to act as a lookup and track characters?

    Im very confused.

  2. #2
    Addicted Member
    Join Date
    Nov 2000
    Location
    North East (UK)
    Posts
    204
    You could try doing something like;

    character table:
    character ID (Primary Key)
    character name
    blah!!!!!

    Appearances Table:
    Appearance ID (Primary Key)
    Character ID (Foreign Key from character table)
    comic ID (Foreign Key from comic table)
    blah!!!!!!

    Comic table:
    comic ID (Primary Key)
    comic title
    blah!!!!!!

    The primary keys in the character and comic tables become the foreign keys in the appearances table. This will reduce your relationships from m:m to 1:m.

    Hope this helps

    Colin

  3. #3
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    That's the right design.

    In such cases, you need to have two master or Reference tables and a relation table, which tracks the relationship between the master entities.

    In the structure above, the Character and the Comic are the master or reference tables, while the Appearances table is the Relation table. Just like the Character and the Comic tables have a primary key, the primary key of the Appearances table could be said to be the Character ID + Comic ID combination. You may or may not have a generic primary key for this table like the Appearance ID.

    This type of structure makes it easy to add/remove characters from comics. If you want to include a character into a comic, simply add a record to the Appearances table with the desired Comic ID and the Character ID of the character to be added. Or if you want to remove a character from a comic, locate and remove the corresponding record from the Appearances table.
    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

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