Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2012

    Unanswered: FK Constraint from one column to two different tables

    Hello, I have a requirement where one column of a table is supposed to have two foreign key constraints i.e. it can be referring to two different columns in two tables.

  2. #2
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    No, it is not possible for one column to be a foreign key to two different tables, although there is a workaround for it.

    Create a "parent" table, which I'll call merchandise that contains basic information such as cost, department, availability, etc. that applies to all merchandise. Create two subordinate tables as goods and services which inherit their primary key from merchandise and provide more specific information.

    When you want to sell something, you can sell merchandise (declare an FK to merchandies) without knowing or caring whether the item sold was goods or services!

    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Posting Permissions

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