Multiple foreignkey in single column

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • parameswari
    New Member
    • Oct 2011
    • 1

    Multiple foreignkey in single column

    Hi Friends,

    I have a problem in creating a table with a column that has two foreign Key relationship . Let me explain in detail.

    Say ,I have three tables. First table A which has column A.ID(Primary Key),A.Name. Second Table B has Column B.ID(Primary Key),B.Name. Third Table C has Column C.ID ,C.Name,C.Detai l.
    In C.Detail I have to store data from both table(A.ID & B.ID). So I tried to add two foreign key into the column C.Detail. During Insert Operation in Table B the following error occurs. The error Message is ViceVersa while trying to insert data into the Table A.


    > "The INSERT statement conflicted with the FOREIGN KEY constraint
    > "FK_C_A". The conflict occurred in database "X", table "dbo.A", column
    > A.ID."

    Please, Can any one help us to rectify this problem . We doesnt want to seperate columns in table C for two foreign key.

    Hopefully waiting for the reply.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32654

    #2
    Originally posted by Parameswari
    Parameswari:
    We doesnt want to seperate columns in table C for two foreign key.
    I'm afraid there is no alternative. I'm not sure what ever gave you the idea that a key relationship could be set up to link only a part of a field, but I've never come across that situation anywhere. It's a strange concept to say the least.

    Comment

    Working...