What is the difference between Primary key and prime attribute? What is the difference between Primary key and prime attribute? database database

What is the difference between Primary key and prime attribute?


A candidate key is a key that uniquely identifies rows in a table. Any of the identified candidate keys can be used as the table's primary key. Candidate keys that are not part of the primary key are called alternate keys. One can describe a candidate key as a super key that contains only the minimum number of columns necessary to determine uniqueness.

Prime attributes are the attributes of the candidate key which defines the uniqueness (Eg: SSN number in an employee database)

A primary key is a column in a table whose values uniquely identify the rows in the table. The primary key is chosen from this list of candidates based on its perceived value to the business as an identifier.

A primary key value:

  • Must uniquely identify the row;
  • cannot have NULL values;
  • Should not change over the time;
  • and Should be as short as possible.

If the primary key is a combination of more than one column then it is called as composite key.


In order to understand the difference primary key and prime attributes, one should first know what is a super and candidate key.

Super Key: Any attribute/combination of attributes whose closure, onthe basis of given functional dependencies, determines thecomplete relation is a Super Key. (A relation could have more than one super keys)

For example in relation R(A,B,C,D);given the functional dependencies as:

ABC->D

AB->CD

A->BCD

D->ABC

Following are the super keys

ABC; because its closure gives the complete relation i.e., (ABC)->ABCD

AB; because it's closer also gives the complete relation i.e., (AB)->ABCD

A; because it's closure also gives the complete relation i.e., (A)->ABCD

D; because it's closure also gives the complete relation i.e., (D)->ABCD

Candidate Key: Any super key whose proper subset is not a super key is aCandidate Key. (A relation could have more than one candidate keys)

So, in the example above, A and D are the only candidate keys.

Primary Key: Any candidate key (may or may not be minimal) which is being chosen by the database designer to identify record is a Primary Key. (A relation can have only one primary key/(composite primary key: primary key that is made up of more than one columns))

In the example above, A (let's say) is the primary key.

Prime Attributes: An attribute that is present in any of the candidate keys is a prime attribute.

So, in the example above, A and D are prime attributes.


Primary keys may consist of a single attribute or multiple attributes in combination.For example

name login emailBob  catlover catlover@123.comJason doglover doglover@123.com

The login would be the primary key and the attribute will be the catlover/doglover everything that is attributed in that key