Keys in RDBMS or DBMS
sawant-infotech

Keys in RDBMS or DBMS

 Keys In Relational Database Management System (RDBMS)

In This Article We See  :

  • What Is Key ?
  • What Are The Types Of Keys ?

What Is Key ?
  • A Keys Refers To An Attribute or Set Of Attributes That Help Us Identify A Row or Tuple Uniquely In A Table or Relation.
  • A Key Is Also Used When We Want To Establish  Relationship Between The Different Columns And Tables Of A Relational Database.
  • A Key Pal An Important Role IN The Relational Database
  • It Is Used To Uniquely Identify Any Record Or Row Of Data From The Table. It Is Also Used To Establish And Identify Relationship Between Tables.
  • For Example, Stud_Id Is Used As A Key In The Student Table Because It Is Unique For Each Student 

What Are The Types Of Keys ?


  1. Primary Key
    • It is the first key used to identify one and only one instance of an entity uniquely. An entity can contain multiple keys, as we saw in the PERSON table. The key which is most suitable from those lists becomes a primary key.
    • In the EMPLOYEE table, ID can be the primary key since it is unique for each employee. In the EMPLOYEE table, we can even select License_Number and Passport_Number as primary keys since they are also unique.
    • For each entity, the primary key selection is based on requirements and developers.
    • For Example, In Following Example Roll_No Is Primary Key.


  2. Candidate Key
    • A candidate key is an attribute or set of attributes that can uniquely identify a tuple.
    • Except for the primary key, the remaining attributes are considered a candidate key. The candidate keys are as strong as the primary key.
    • For Example, In Following Example Roll_No  And Phone Are Candidate Keys.

  3. Super Key
    • Super key is an attribute set that can uniquely identify a tuple. A super key is a superset of a candidate key.
    • For Example, From Above Example (Candidate Key Example), {Roll_No, Name}, {Roll_No, Age}, Etc.

  4. Foreign Key
    • Foreign keys are the column of the table used to point to the primary key of another table.
    • Every employee works in a specific department in a company, and employee and department are two different entities. So we can't store the department's information in the employee table. That's why we link these two tables through the primary key of one table.
    • We add the primary key of the STUDENT_MARKS table, Course_Id, as a new attribute in the STUDENT table.
    • In the STUDENT_DETAILS table, Course_ID,is the foreign key, and both the tables are related.


  5. Alternate Key
    • There may be one or more attributes or a combination of attributes that uniquely identify each tuple in a relation. These attributes or combinations of the attributes are called the candidate keys. 
    • One key is chosen as the primary key from these candidate keys, and the remaining candidate key, if it exists, is termed the alternate key. 
    • In other words, total number of the alternate keys is the total number of candidate keys minus the primary key. The alternate key may or may not exist. If there is only one candidate key in a relation, it does not have an alternate key.


  6. Composite Key
    • Whenever A Primary Key Consists Of More Than One Attribute, It Is Known As A Composite Key. This Key Is Known As Concatenated Key.
  7. Artificial key
    • The key created using arbitrarily assigned data are known as artificial keys. These keys are created when a primary key is large and complex and has no relationship with many other relations. The data values of the artificial keys are usually numbered in a serial order.





Like 👍 Comment 😀 Share 😘 Subscribe ❤️
Instagram @sawant.infotech Gmail sawant.infotech.14@gmail.com 🙏 🙏 🌹🌹🌹🌹🌹🌹 🌹🌹 Thanks 😊❤️ 🌹🌹🌹 Like ❤️ 🌹🌹🌹🌹 Comment 😊 🌹🌹🌹🌹🌹 Share 🤟🏻 🌹🌹🌹🌹 Subscribe 😘. 🌹🌹🌹 🌹 🌹🌹🌹🌹🌹🌹🌹

If Any Query Please Post In Comment Section, We Will Reply As Soon As Possible 🙏


Post a Comment

Previous Post Next Post