Primary key and Foreign key on same column
450923Jan 10 2006 — edited Jan 11 2006Hi, I am able to create below tables , primary and foreign keys as below.
But Is this valid design? Can I define a column (ckey2 in table "child") as
primary key and as well as foreign key?
CREATE TABLE parent (
col1 NUMBER,
col2 NUMBER
);
CREATE TABLE child (
ckey1 NUMBER,
ckey2 NUMBER,
ckey3 NUMBER
);
alter table parent add constraint parent_pk primary key( col1 );
alter table child add constraint child_pk primary key( ckey2 );
alter table child add constraint child_fk foreign key( ckey2 ) references parent( col1);
Thanks.