Hi techies, in this article we are going to discuss about different types of keys in database management system. That keys are very important for any data schema or in entity set to retrieve or modify the data. So lets dive into topic.
DBMS Keys Definition:
No two entities in any entity set are allowed to have exactly the same value for all attributes. The set of attributes that are distinguish entities from each other.
Keys are the attributes of the entity, which uniquely identifies the record of the entity. For example STUDENT_ID identifies individual students.
Or passport# and license# also do the same thing to identifying any record uniquely in entity set.
Types of keys:
As we have seen already, there are different types of keys in the database. So following are:
Super Key is the one or more attributes of the entity, which uniquely identifies the record in the database.
Candidate Key is one or more set of keys of the entity. Or subset of super keys.
For example: a person entity, his SSN, passport#, license# etc. can be a super key.
Primary Key is the candidate key, which will be used to uniquely identify a record by the query. Though a person can be identified using his SSN, passport# or license#, one can choose any one of them as primary key to uniquely identify a person. Rest of them will act as a candidate key.
(Figure: "Person" Entity Set)
Foreign Key of the entity attribute in the entity which is the primary key of the related entity. Foreign key helps to establish the mapping between two or more entities.
That’s it for today. If you like this article do share with your friends and others. Till than have a good day.