Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2011
    Posts
    16

    Unanswered: Primary And Foreign keys.

    Hi,
    I have a Main table with 7 Primary keys.
    I also have a Child table which I want to relate it to Main table via Foreign keys.
    Can I use the 6 Foreign keys in Child Table as reference to only the 6 primary keys instead of 7 to the Main Table.
    When I am doing this I am getting Errors as:-

    SQL State = 42890 SQL Code = -573 SQL Message = A column list specified in the references clause of constraint "FL_DESIG..." does not identify a unique constraint of the parent table or nickname "MBID.TMST". Exception message = com.ibm.db2.jcc.c.SqlException: A column list specified in the references clause of constraint "FLI_DESIG..." does not identify a unique constraint of the parent table or nickname "MBID.TMST".

  2. #2
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    one table can only keep 1 primary key
    different foreign keys can point to the same pk
    see
    Designing primary key constraints
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

  3. #3
    Join Date
    Jul 2011
    Posts
    16
    But I wanted those senev columns to uniquely define my rows.
    And in the Child key a foreign key of six.

  4. #4
    Join Date
    May 2009
    Posts
    508
    Provided Answers: 1
    pratikp.vasani, I think what you mean is you have 1 Primary key consisting of 7 columns. You have another table where you want to create a RI rule based on 6 columns from the Child table to only 6 of the 7 columns in the Primary Key on the Parent table.

    The answer is No, you can't do that. If you have 7 columns in the Primary Key, the the Foreign Key also has to have 7 columns.

Posting Permissions

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