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 > Relational DB modelling strange relationships with(out) foreign key constraint

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-09-12, 12:58
s2cuts s2cuts is offline
Registered User
 
Join Date: Feb 2012
Posts: 1
Relational DB modelling strange relationships with(out) foreign key constraint

Hello all,

I have a class of tables which I need to relate to a single table. Ideally, I would like to make use of DB foreign key constrains (as the rest of the app has done), however there are some issues with respect to the relationship that makes this a bit difficult. I'll discuss the details below.

Let's say I have a class of similar tables (A1, A2, A3). Logically, these are the parent tables which have related children in table B. I'm struggling with how to implement a foreign key on table B that is constrained to the primary key of table A1 OR table A2 OR table A3.

The only options I see are to forgo FK constraints at the DB layer, or duplicate an identical table B for each of the A tables (A1->B1, A2->B2, A3->B3).

Any insight or advice would be greatly appreciated.
Reply With Quote
  #2 (permalink)  
Old 02-09-12, 16:06
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
advice would be a lot easier to come up with if we were talking about actual tables instead of As and Bs

a foreign key relationship can reference only one table

so if a table has to reference three different tables, it'll need three different foreign keys
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Tags
foreign key, modelling, relational database

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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