Thursday, August 25, 2011

DIFFRENT TYPES OF SQL KEYS


SQL KEYS

Candidate Key - A Candidate Key can be any column or a combination of columns that can qualify as unique key in database

. There can be multiple Candidate Keys in one table. Each Candidate Key can qualify as Primary Key.
Primary Key - A Primary Key is a column or a combination of columns that uniquely identify a record. Only one Candidate Key can be Primary Key.
One needs to be very careful in selecting the Primary Key as an incorrect selection can adversely impact the database architect and future normalization. For a Candidate Key to qualify as a Primary Key, it should be Non-NULL and unique in any domain. I have observed quite often that Primary Keys are seldom changed. I would like to have your feedback on not changing a Primary Key.


Candidate keys->   A candidate key is a combination of
attributes that can be uniquely used to identify a database
record without any extraneous data. Each table may have one
or more candidate keys. One of these candidate keys is
selected as the table primary key.

Alternate keys->   Alternate Key or Unique Key is similar to
PK ,except it accepts null Values .So that the records can
still be entered submitting null values to this attribute.

Composite keys->   compound key (also called a composite key
or concatenated key) is a key that consists of 2 or more
attributes.
         A composite Key can be either Primay or Unique
Key.More then One Key columns are said to be composite keys

No comments:

Post a Comment