Data Warehousing Community Forum
February 10, 2012, 12:57:01 am

Pages: [1]   Go Down
  Print  
Author Topic: Difference bwn Primary Key, Unique Key and Surrogate Key  (Read 985 times)
Sowjanya
DW Fresher
*

Reputation: +1/-0
Offline Offline

Posts: 9


View Profile
« on: December 12, 2007, 05:37:56 pm »

Hi

can anyone help me in explaining the difference between Primary Key, Unique Key and Surrogate key?


Thanks
Sowjanya
Logged
Sipra
Founder
*****

Reputation: +59/-0
Offline Offline

Posts: 323


Am the King...


View Profile WWW
« Reply #1 on: December 13, 2007, 03:13:03 pm »

Simple definitions for Primary Key, Unique Key and Surrogate Key --

Primary Key -
A primary key is used to uniquely identify each row in a table.
A primary key value cannot be NULL

Unique Key -
It is also defined similar to that of primary key with the following difference -
Unique keys are the keys where the implicit NOT NULL constraint is not automatically enforced, while for primary keys it ispresenet. Thus, the values in a unique key columns may or may not be NULL.

Surrogate Key -
A surrogate key is a artificial synthetic key which has same meaning through out the database. It is system generated key with no business value. Usually implemented with database generated sequences.

Hope this helps to some extent...!
Logged

Sowjanya
DW Fresher
*

Reputation: +1/-0
Offline Offline

Posts: 9


View Profile
« Reply #2 on: December 13, 2007, 03:31:58 pm »

Thanks a lot Sipra  Smiley
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: