Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2010
    Posts
    57

    I need a FK to point to different tables - but don't know which a priori

    I have a situation that I really don't know how to implement in a database. Please forgive me if I don't use quite the right terminology, I'm a coder but new at DBs.

    I have a table of events. In the table there are the columns you might expect: date, creator, event type, brief description.

    So far quite trivial. However, now I want to link up each event to a record in a different table that contains more information specific to the event. The problem is that the table to link to is different depending on the event type.

    For instance, a hardware malfunction event might link to a table containing information about the hardware, serial number, model, etc; whereas a human error event might link to a table containing procedure number, step number, and so forth.

    In C++ I would implement something like this by a pointer to a base class from which the specific event description table classes are derived.

    Is there a recommended/proper way of doing this in an RDBMS?

    Thanks!
    Carlos

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by carlosn View Post
    In C++ I would implement something like this by a pointer to a base class from which the specific event description table classes are derived.
    in a relational database, you would have a base supertype entity table which has the specific resources -- hardware, procedure, etc. -- as subtype entity tables
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Aug 2010
    Posts
    57

    Say what?

    Quote Originally Posted by r937 View Post
    in a relational database, you would have a base supertype entity table which has the specific resources -- hardware, procedure, etc. -- as subtype entity tables
    R937 - Thanks for your reply(s). I'm afraid you have lost me... Can you point me to a location/resources where supertypes are explained?

    Carlos

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by carlosn View Post
    Can you point me to a location/resources where supertypes are explained?
    first half dozen or so sites here --> http://lmgtfy.com/?q=supertypes+and+subtypes

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Aug 2010
    Posts
    57
    I'll ignore the sarcasm and thank you for the pointer.... I'll be doing some reading today .

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by carlosn View Post
    I'll ignore the sarcasm ...
    any sarcasm was inferred, not implied

    it was simply the easiest way to give you a lot of quality links
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  7. #7
    Join Date
    Aug 2010
    Posts
    57
    Thank you for the information. I've started the design, and have some implementation specific questions that I've posted in a new 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
  •