What is difference between primary key and foreign key?

A primary key is an attribute (or combination of attributes) that uniquely identifies each row in a relation. A primary key is designated by underlining the attribute name. The primary key of an entity set allows us to distinguish among the various entities of the set.

A foreign key is an attribute in a relation of database that serves as the primary key of another relation in the same database.

 

Improve Answer Discuss the question "What is difference between primary key and foreign key?" Watch Question

First answer by Gcutter. Last edit by Harithaveni. Contributor trust: 8 [recommend contributor]. Question popularity: 37 [recommend question]


Research your answer:

Can you answer other questions about computers and the net?

Answers.com > Wiki Answers > Categories > Technology > Computers > What is difference between primary key and foreign key?

Our contributors said this page should be displayed for the questions below. (Where do these come from)
If any of these are not a genuine rephrasing of the question, please help out and edit these alternates.
Types of dbms?  What is the DBMS?  Foreign key means?  What is foreign key?  Primary key indexing?  What is a primary key?  Primary and foreign key?  Primary key and uniq key?  What does primarykey mean?  Primarykey amd foreign key?  What is primary forigen key?  Primary key and foreign key?  What is primary key in DBMS?  What is Primary Foreign Key?  What is a foreign key in a database?  Advantages of primary key of database?  What is primary key define with example?  Difference between primary and foreign key?  How do you declare foreign key in db2 table?  Differens between primarykey and foreign key?