Lec-9: What is Primary Key in DBMS | Primary Key with Examples in Hindi

Lec-9: What is Primary Key in DBMS | Primary Key with Examples in Hindi

What is a Primary Key in DBMS?

Introduction to Keys in Database Management Systems

  • The concept of keys is crucial in Database Management Systems (DBMS), relevant for competitive exams, college/university assessments, and job placements.
  • This video focuses specifically on the primary key, emphasizing its importance across various database operations including normalization and SQL.

Understanding the Primary Key with an Example

  • To illustrate the primary key's role, an example involving 100 students is presented. Data such as registration number, roll number, names, age, gender, and contact details are stored in a table format.
  • The need for unique identification arises when managing student data; hence the concept of a "key" becomes essential.

Defining Keys: Unique Identification

  • A key functions similarly to a physical lock and key system—each lock has a unique key that opens it. In databases, this means uniquely identifying records.
  • Unlike common attributes like names or ages which may not be unique among students, keys must ensure distinctiveness to avoid confusion.

Candidate Keys: Attributes with Unique Values

  • Attributes such as phone numbers or Aadhaar card numbers serve as candidate keys because they are expected to have unique values across different entries.
  • Other examples include registration numbers or roll numbers assigned by educational institutions that guarantee uniqueness.

Limitations of Candidate Keys

  • While candidate keys are unique identifiers, their reliability can be compromised if students do not provide accurate information (e.g., incorrect phone numbers).
  • There’s also the possibility of siblings sharing the same phone number or other attributes leading to potential duplication issues within the database.

Null Values and Their Implications

  • Not all students may provide certain information (like phone numbers), resulting in null values that complicate data retrieval processes.

Understanding Primary Keys in Databases

The Importance of Unique Identification

  • Each entry in a database must be uniquely identifiable; multiple entries for a single student indicate a lack of uniqueness.
  • A field cannot be left empty (not null); it must contain valid data, such as a phone number or identification number.

Handling Null Values

  • If a required field is not filled correctly, it leads to incorrect database entries. For example, entering invalid characters just to avoid leaving the field empty is problematic.
  • Institutions may require mandatory fields like Aadhaar card numbers for admission; failure to provide these can result in denial of admission.

Defining Primary Keys

  • A primary key must be both unique and not null, ensuring that each record can be distinctly identified without any duplicates.
  • In smaller colleges, roll numbers may serve as primary keys, while larger institutions might use registration numbers due to their uniqueness.

Generation and Assignment of Primary Keys

  • Users do not choose their primary keys; they are assigned automatically by the institution (e.g., registration or roll numbers).
  • Similar processes occur at passport offices where passport numbers are generated and assigned as unique identifiers.

Constraints on Primary Keys

  • Both uniqueness and non-null constraints make defining primary keys challenging; they cannot have duplicate values or remain empty.
  • While candidate keys can exist without being mandatory (can be null), only one primary key is allowed per table due to its strict requirements.

Candidate Keys vs. Primary Keys

  • Multiple candidate keys can exist within a database, but only one can be designated as the primary key because it fulfills both uniqueness and non-null criteria.
Video description

👉Subscribe to our new channel:https://www.youtube.com/@varunainashots ► Database Management System(Complete Playlist): https://www.youtube.com/playlist?list=PLxCzCOWd7aiFAN6I8CuViBuCdJgiOkT2Y Other subject-wise playlist Links: -------------------------------------------------------------------------------------------------------------------------------------- ►Design and Analysis of algorithms (DAA): https://www.youtube.com/playlist?list=PLxCzCOWd7aiHcmS4i14bI0VrMbZTUvlTa ►Computer Architecture (Complete Playlist): https://www.youtube.com/playlist?list=PLxCzCOWd7aiHMonh3G6QNKq53C6oNXGrX ► Theory of Computation https://www.youtube.com/playlist?list=PLxCzCOWd7aiFM9Lj5G9G_76adtyb4ef7i ►Artificial Intelligence: https://www.youtube.com/playlist?list=PLxCzCOWd7aiHGhOHV-nwb0HR5US5GFKFI ►Computer Networks (Complete Playlist): https://www.youtube.com/playlist?list=PLxCzCOWd7aiGFBD2-2joCpWOLUrDLvVV_ ►Operating System: https://www.youtube.com/playlist?list=PLxCzCOWd7aiGz9donHRrE9I3Mwn6XdP8p ►Structured Query Language (SQL): https://www.youtube.com/playlist?list=PLxCzCOWd7aiHqU4HKL7-SITyuSIcD93id ►Discrete Mathematics: https://www.youtube.com/playlist?list=PLxCzCOWd7aiH2wwES9vPWsEL6ipTaUSl3 ►Compiler Design: https://www.youtube.com/playlist?list=PLxCzCOWd7aiEKtKSIHYusizkESC42diyc ►Number System: https://www.youtube.com/playlist?list=PLxCzCOWd7aiFOet6KEEqDff1aXEGLdUzn ►Cloud Computing & BIG Data: https://www.youtube.com/playlist?list=PLxCzCOWd7aiHRHVUtR-O52MsrdUSrzuy4 ►Software Engineering: https://www.youtube.com/playlist?list=PLxCzCOWd7aiEed7SKZBnC6ypFDWYLRvB2 ►Data Structure: https://www.youtube.com/playlist?list=PLxCzCOWd7aiEwaANNt3OqJPVIxwp2ebiT ►Graph Theory: https://www.youtube.com/playlist?list=PLxCzCOWd7aiG0M5FqjyoqB20Edk0tyzVt ►Programming in C: https://www.youtube.com/playlist?list=PLxCzCOWd7aiGmiGl_DOuRMJYG8tOVuapB ►Digital Logic: https://www.youtube.com/playlist?list=PLxCzCOWd7aiGmXg4NoX6R31AsC5LeCPHe --------------------------------------------------------------------------------------------------------------------------------------- Our social media Links: ► Subscribe to us on YouTube: https://www.youtube.com/gatesmashers ►Subscribe to our new channel: https://www.youtube.com/@varunainashots ► Like our page on Facebook: https://www.facebook.com/gatesmashers ► Follow us on Instagram: https://www.instagram.com/gate.smashers ► Follow us on Instagram: https://www.instagram.com/varunainashots ► Follow us on Telegram: https://t.me/gatesmashersofficial ► Follow us on Threads: https://www.threads.net/@gate.smashers -------------------------------------------------------------------------------------------------------------------------------------- ►For Any Query, Suggestion or notes contribution: Email us at: gatesmashers2018@gmail.com #PrimaryKey#DBMS#collegeUniversityExams#GATE#UGCNET#nielit#psu#placements