What is the difference between Primary key and prime attribute?

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

name login email
Bob  catlover [email protected]
Jason doglover [email protected]

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


Student_table {IndexNo,Name,ExamNo,Age,Class,City}

  • {IndexNo},{Name,ExamNo} are the candidates keys. From them I'ill choose {IndexNo} as the Primary Key.Those all indexNo,Name,ExamNo are prime attributes

Employee_table {ID,Name,MobileNo,Age,Height}

  • {ID},{MobileNo} are the candidates keys. From them I'ill choose {ID} as the Primary Key.Those all ID,MobileNo attributes are prime attributes

Lets Look at the definitions. (Attributes mean columns)

Candidate key - Attributes or combination of attributes that can used to uniquely identify table records.

Prime key - Attribute that forms candidate keys.

Primary Key - A attribute from candidate keys, Than used to Uniquely identify the table records.It should Unique, Not Null, Should not update frequently.


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, on the basis of given functional dependencies, determines the complete 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 a Candidate 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.


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.

Tags:

Database

Rdbms