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 > Multiple Foreign Keys

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-07-09, 22:54
gertnerbot gertnerbot is offline
Registered User
 
Join Date: Nov 2009
Posts: 1
Multiple Foreign Keys

In a simple design, is it possible to have multiple foreign keys in one table? I'm thinking that would cause some integrity constraints on the database itself when creating reports. Maybe I'm wrong.
Reply With Quote
  #2 (permalink)  
Old 11-07-09, 23:15
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by gertnerbot View Post
In a simple design, is it possible to have multiple foreign keys in one table?
sure

classic example: orderitems table has a FK to orders table, and another FK to items (products) table
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 11-08-09, 00:32
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,246
its also possible to have multiple foreign keys pointing to the same table

eg table orders
say you have an order process that requires you to track who raised the order, who authorised it, and who actually placed the order. depending on how you modelled that it may require 3 person ID's in the order header all pointing to the same table.

if its required by the business processes, its required in the model. its easier, more straightforward to build such constraints/rules int eh db than to delegate such rules to the applciation software/front end
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
Reply

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