Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2010
    Posts
    9

    Question table structure for inbox

    Hi
    I am trying to create inbox table in which entries may came from multiple tables. For example in my inbox entries may be received memos and and received circulars.
    How can i have multiple foreign keys to the inbox table. One option may be to add foreign key for each parent table. I want to make design flexible so that if in future if i want to join more tables with this inbox table it can be done easily.
    I read somewhere about composite foreign keys does they apply here?

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    You can add as many foreign keys as the design requires, and if the design requires it you can have composite foreign keys too.

    There is not enough information to give you answers specific to your situation.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Jun 2010
    Posts
    9

    Post

    Thanks for the reply. could you please define composite foreign key for me and when it is used.
    is there any way to workaround multiple foreign keys.
    In my case Memo tables are as follows
    ==========
    MemoMaster
    ==========
    MemoID PK
    ThroughEmpID FK
    MemoDate
    Subject
    MemoText
    ==========
    MemoDetail
    ==========
    MemoDetailID PK
    MemoID FK
    EmployeeID FK
    AckDate

    Almost similar structure is for Circular

    Can you suggest the possible inbox table structure

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    A composite foreign key is used in all but the most trivial databases that use natural keys for the primary keys.
    I don't know if you are using surrogate keys or not, but looking at what you have posted it seems likely, in which case you would not use composite foreign keys.

    NOTE that "multiple foreign keys" and "composite foreign keys" are not the same thing.

    It seems to me you could do with stopping now and reading up relational database design and concepts. This is the best whistle stop tour of the subject I know of:
    The Relational Data Model, Normalisation and effective Database Design
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    sounds like you want some for of sub/super types

    top level table identifies a type of message/communication
    and stores all relevent data common to all forms of communication
    then for each type you hav a sub table which stores datat relevent to just that communication

    so that could be
    table: inbox
    id
    communicationtype
    timeofevent

    emailtable
    inboxID
    emailfrom
    emailcontents

    memo
    ID
    inboxid
    URLtoDocument

    telecon
    ID
    inboxid
    whowith
    notesofconversation

    suggest you google sub/super types
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    Jun 2010
    Posts
    9
    Thanks for your reply i will get back to u soon after studying as u suggested
    Last edited by tassadaque; 08-17-10 at 04:53.

Tags for this Thread

Posting Permissions

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