What is Candidate Key in DBMS?
A Candidate Key in DBMS is a minimal set of columns/attributes that can be used to uniquely identify a single/every tuple or row in a relation.
Candidate Keys are determined during database design based on the underlying business rules of the database.
After finding all possible candidate keys in a relation.DBA choose one key as a primary key.
Consider the following relation in the context of a business firm:
Employee(EmpNo, Name, AadharNo, Salary, DOB)
Let us try to identify some candidate keys for this relation
|Empno||This seems to be good candidate key as companies usually issue a unique no for each employee.|
|Adharno||This seems to be good candidate key for a company that is based in India.|
|Name, DOB||This might work for a small organization of 5 to 10 people as a combination of name and DOB is unique.|
|Salary||This is not a good candidate key as salary is paid uniformly tp people at the same level.|
|Empno, DOB||It is not a candidate key as empno alone is unique. Because only a minimal set of an attribute can be candidate key.|
For other interesting technical blog Article click here
Candidate key vs Primary key-
There are few differences between candidate key and primary key. In a table it may be there is more than one candidate key exist.
But in a table, only one primary key can exist. The primary key is also a candidate key but the only difference is one of the candidate key work as a primary key.
Show the main purpose of this key is to identify the rows uniquely. it means any column or combination of a column which is minimal and by which we can uniquely identify the rows.
Now you can easily understand the concept of candidate key.
If you have any query on database management system then comment your questions