Primary key and Foreign key

<<Previous   Next>>

Database - Primary key and Foreign key - April 01, 2009, 19:10 pm by Nishant Kumar

Define Primary key and Foreign key. 

A column or combination of columns that identify a row of data in a table is Primary Key.

A key in a table that identifies records in other table in called a foriegn key.

Primary key and unique key

Both are used to provide uniqueness of the column.
Primary key creates clustered key on the column by default whereas unique key creates non-clustered index by default.
Primary doesn't allow NULL values whereas unique key can allow one NULL value. 

Database - Primary key and Foreign key - Jan 08, 2010, 15:55 pm by Vidya Sagar

Define Primary key and foreign key.

Primary Key: Primary key is used for unique identification of each row in a table. Unique and not null values only are accepted to persist in primary key.

Foreign Key: Foreign Key identifies a column with the primary key column of another table (parent table) for storing data. The values in the foreign key must be the values of primary key of other columns. Thus it ensures the data integrity – correct data.

<<Previous   Next>>

Write your comment - Share Knowledge and Experience


Latest placement tests
Latest links
Latest MCQs
» General awareness - Banking » ASP.NET » PL/SQL » Mechanical Engineering
» IAS Prelims GS » Java » Programming Language » Electrical Engineering
» English » C++ » Software Engineering » Electronic Engineering
» Quantitative Aptitude » Oracle » English » Finance
Home | About us | Sitemap | Contact us