If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > I need a FK to point to different tables - but don't know which a priori

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-09-10, 00:57
carlosn carlosn is offline
Registered User
 
Join Date: Aug 2010
Posts: 48
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
Reply With Quote
  #2 (permalink)  
Old 08-09-10, 02:39
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,085
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 08-09-10, 09:56
carlosn carlosn is offline
Registered User
 
Join Date: Aug 2010
Posts: 48
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
Reply With Quote
  #4 (permalink)  
Old 08-09-10, 10:01
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,085
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

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 08-09-10, 10:08
carlosn carlosn is offline
Registered User
 
Join Date: Aug 2010
Posts: 48
I'll ignore the sarcasm and thank you for the pointer.... I'll be doing some reading today .
Reply With Quote
  #6 (permalink)  
Old 08-09-10, 10:17
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,085
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 08-18-10, 12:49
carlosn carlosn is offline
Registered User
 
Join Date: Aug 2010
Posts: 48
Thank you for the information. I've started the design, and have some implementation specific questions that I've posted in a new thread.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On