neha
Answered On : Nov 22nd, 2006
yes u can,foreign key is used to cut short the repeated use of primary key data.

1 User has rated as useful.
Login to rate this answer.
yes , v can have.
Foreign key is used to make relationship with another table.V can think foreign key as a copy of primary key from another relational table.
Login to rate this answer.
manu
Answered On : Feb 22nd, 2007
yes it possible 2 have foriegn key constraint on the same table where there is a primary key.this is can done by adding a constraint to the table using alter table tblname . the refernce column and table being the base table.
thus one table can have both primary key as well as foreign key constraint.
Login to rate this answer.
Nikhil_4_Oracle
Answered On : Mar 15th, 2007
Dear All,
Yes its possible.
Alter table reftab add constraint pk_reftab_col1 primary key;
Alter table reftab add constraint fk_reftab_col2 (col2) references reftab (clo1);
it will work....But there is no sence in doing so..u wll just make duplicate data in same table. Also it will increases the data redudancy...
Regards,
Nikhil
Login to rate this answer.
Shri
Answered On : Nov 1st, 2007
Dear Vivek,
If I understand your question well, you mean to say that "is there any possibility to have bothprimary & foreign keys in the same table".
Well, the answer is No. The foreign key (by definition) in a table is the key which is the reference of primary key of different table i.e. the foreign key in a table is theprimary keyof another table. Therefore, in order to make use of foreign key concept, the tables should be different (one containing primary key while other containing foreign key).
(Please let me know for any issues).
Login to rate this answer.
Yes it is possible to have primary key and foreign key in one table.
For e.g the schema for table category is as follows
Category_id: int primary key
Category_title: varchar(30)
parent_id: int(3)
In the above table schema column "parent_id" is used to denote parent category id which references "category_id" column in same table.
Login to rate this answer.