Results 1 to 3 of 3
  1. #1
    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.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    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 on the Tiger 800 or the Norton

Posting Permissions

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