Discuss between primary key and candidate key.

Discuss between primary key and candidate key.

Ans.  A primary key may be composed of one single attribute, or it may be composed of more than one attribute. A primary key is used to identify uniquely the tuples or rows of a relation, no value of the attribute or attributes that form the primary key can be NULL. This fact imposes an additional restriction, or constraint, on the primary key known as the integrity constraint. A NULL value represents missing information, unknown, or inapplicable data. The reader should be aware that a NULL value is not a zero value, unknown, or does it represent a particular value within the computer.

(i) primary key – A primary key may be composed of one single attribute, or it may be composed of more than one attribute. A primary key is used to identify uniquely the tuples or rows of a relation, no value of the attribute or attributes that form the primary key can be NULL. This fact imposes an additional restriction, or constraint, on the primary key known as the integrity constraint. A NULL value represents missing information, unknown, or inapplicable data. The reader should be aware that a NULL value is not a zero value, unknown, or does it represent a particular value within the computer.

(ii)Candidate key – A set S of attributes of relation R is a candidate key for R if and only if the set satisfies the following conditions –

  • No proper subset of set s satisfies the uniqueness property
  • For two distinct tuples t1 and t2 of relation R, th4ere exists an attribute A of S such that

T1 (A)  t2 (A)

For example, a combination of customer_name and customer_street is sufficient to distinguish among members of the customer entity set. Then, both {customer_id} and {customer_name, customer_street} are candidate keys. Although the attributes customer_id and customer_name together can distinguish customer entities, their  combination does not for a candidate key, since the attribute customer_id alone is a candidate key.

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *