Question:
Whet are the difference between primary key and foreign key?
Answer:
1)Primary key is unique key but foriegn key always refers to primary key.
2) Primary keys enforce entity integrity by uniquely identifying entity instances. Foreign keys enforce.
3)Primary key is unique primary key is not NULL and foreign key is NULL foreign key reference as Primary key in another table.
4) primary key is used to identify a row and it doesnot allow null values. It avoids duplication of rows.
whereas foreign key refers to a column or combination of columns included in the defenition of referential integrity.
referential integrity by completing an association between two entities. Source: CoolInterview.com
Answered by: R.V.R,Krishna Chaitanya | Date: 5/23/2008
| Contact R.V.R,Krishna Chaitanya
)Primary key is unique key but foriegn key always refers to primary key. Source: CoolInterview.com
Answered by: abhijit yashwantrao | Date: 3/5/2010
| Contact abhijit yashwantrao
Primary key is unique and use to avoids duplication. primary key can not be NULL and
foreign key can be NULL foreign key is use to reference Primary key in same or another table. Source: CoolInterview.com
Answered by: Savita Khadse | Date: 4/4/2010
| Contact Savita Khadse
I want to add............ One table can have one primary key. But more then one foreign key Source: CoolInterview.com
Answered by: Ishak | Date: 4/19/2010
| Contact Ishak
primary key is unique, it is NOT NULL, only one primary key is allowed in table
A table can have more than one foreign key, it can be NULL, foreign key is a refernce to the primary key of other table Source: CoolInterview.com
Answered by: anil | Date: 5/25/2010
| Contact anil
Primary is always unique .It never null,without primary key we can't identify any particular value in table.Primary key can be created one or more than column. That's column is call composite primary key. Source: CoolInterview.com
Answered by: Bikram | Date: 7/29/2010
| Contact Bikram
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|