This discussion is archived
2 Replies Latest reply: Jan 2, 2013 1:50 AM by David Last RSS

composite primary key

don123 Newbie
Currently Being Moderated

Can i include foreign key in composite primary key. I will explain the situation with classical DEPT and EMP table.

In EMP table, can i have composite primary key that includes DEPT number. If it is acceptable, how to add composite primary key in oracle sql data modeler ??

1 - 10
2 - 10
3 - 10
1 - 20
2 - 20
3 - 20

  • 1. Re: composite primary key
    923816 Newbie
    Currently Being Moderated

    Foreign Key establishes relationship between a primary key or a unique key in the same table or different table.In your example emp table have only composite primary key.that means composite value must that dept number may or may not unique value.if you try to set foreign key,it will throw error.

    ORA-02270: no matching unique or primary key for this column-list

    Edited by: Neelan on Jan 1, 2013 10:05 PM
  • 2. Re: composite primary key
    David Last Expert
    Currently Being Moderated

    You can do this in Data Modeler by including the foreign key column(s) in the list of columns for the primary key.



  • Correct Answers - 10 points
  • Helpful Answers - 5 points