SlideShare a Scribd company logo
Types of Keys in Database
Management System
Presented By :- Mrs.
Surkhab Shelly
Why we have Keys in DB?
• A Key is an attribute or a set of attributes
in a relation that identifies a tuple
(record) in a relation.
• The keys are defined in a table to
access or sequence the stored data
quickly and smoothly.
• They are also used to create
relationship between different tables.
Types of Keys in Database
• 1. Primary Key
• 2. Candidate Key
• 3. Alternate Key
• 4. Super Key
• 5. Composite Key
• 6. Foreign Key
• 7. Unique Key
Primary Key
Employee
EmployeeID
EmployeeName
SSN
DeptID
DOB
• Which is Unique & Can’t be have
NULL Value
• The minimal set of attributes (or
attribute) which can uniquely identify the
rows (tuples) in a table is known as a
primary key.Key Points about Primary
Key
• Primary key is use to identify each row
uniquely in a table.
• Primary key cannot have a NULL value.
• Each table can have only one primary
key.
Candidate Key
Employee
EmployeeID
EmployeeName
SSN
DeptID
DOB
• Are individual columns in a table that
qualifies for uniqueness of each
row/tuple.
• A candidate key is an attribute or set of an
attribute which can uniquely identify a
tuple.
• Here in Employee table EmployeeID&
SSN areeligible for a
Primary Key and thus are
Candidate keys.
Dr. Kamal
Gulati
Alternate Key
Employee
EmployeeID
EmployeeName
SSN
DeptID
DOB
• Candidate column other the
Primary column,
like if EmployeeID is set for a
PK then SSN would be the
Alternate key.
Super Key
Employee
EmployeeID
EmployeeNam
e
SSN
DeptID
DOB
• If you add any other Column / Attribute to a
Primary Key then it become a Super Key,
like EmployeeID + EmployeeName is a
Super Key.
• Super key stands for superset of a key.
• The name of two employees can be the same, but
their EMPLYEE_ID can't be the same. Hence, this
combination can also be a key.
The super key would be EMPLOYEE-ID, (EMPLOYEE_ID,
EMPLOYEE-NAME), etc.
• A super key is a set of one of more columns
(attributes) to uniquely identify rows in a table.
Dr. Kamal
Gulati
Composite Key
Employee
EmployeeID
EmployeeName
SSN
DeptID
DOB
• If a table do have a single column that
qualifies for a Candidate key, then you
have to select 2 or more columns to
make a row unique.
• Like if there is no EmployeeID or
SSN columns, then you can make
EmployeeName +
DateOfBirth (DOB) as Composite
Primary Key. But still there can be a
narrow chance of duplicate rows.
Foreign Key
Employee
EmployeeID
EmployeeName
SSN
DeptID
DOB
Department
DeptID
DeptName
•A foreign key is a field in table which is generally a primary key from
another table.
•In other words, if we had a table A with a primary key X that linked to a
table B where X was a field in B, then X would be a foreign key in B.
•A foreign key is those keys which are used to define a relationship
between two or more tables.
•When we want to implement a relationship between two tables then we use
the concept of foreign key.
It is also known as referential integrity.
We can create more than one foreign key per table
Types of keys dbms
Unique Key
• Unique key is same as
primary with the difference
being the existence of null.
• Unique key field allows one
value as NULL value.
Employee
EmployeeID
EmployeeName
SSN
EmailID
DOB
Practical Example
•
• Table R1. Let A,B,C,D,E are the attributes of this
relation.
A→BCDE (This means the attribute 'A' uniquely
determines the other attributes B,C,D,E.)
BC→ADE (This means the attributes 'BC'
jointly determines all the other attributes A,D,E in
the relation.)
• Find the following:
– Primary Key
– Candidate Key
– Super Key
– Composite Key
Table – R1
A
B
C
D
E
Dr. Kamal
Gulati
Answers:
•Primary Key: A
•Candidate Key: A & BC
•Super Key:A, BC, AE, AD &
ABC
•Composite Key: BC
Ad

More Related Content

What's hot (20)

Types of keys in database | SQL
Types of keys in database | SQLTypes of keys in database | SQL
Types of keys in database | SQL
Sumit Pandey
 
Codd's Rules for Relational Database Management Systems
Codd's Rules for Relational Database Management SystemsCodd's Rules for Relational Database Management Systems
Codd's Rules for Relational Database Management Systems
Rajeev Srivastava
 
SQL subquery
SQL subquerySQL subquery
SQL subquery
Vikas Gupta
 
PL/SQL TRIGGERS
PL/SQL TRIGGERSPL/SQL TRIGGERS
PL/SQL TRIGGERS
Lakshman Basnet
 
Relational model
Relational modelRelational model
Relational model
Dabbal Singh Mahara
 
MySQL JOINS
MySQL JOINSMySQL JOINS
MySQL JOINS
HripsimeGhaltaghchya
 
Advantages of DBMS
Advantages of DBMSAdvantages of DBMS
Advantages of DBMS
harshith singh
 
Data models
Data modelsData models
Data models
Thakshayini Chandramohan
 
Trigger
TriggerTrigger
Trigger
VForce Infotech
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
Sql DML
Sql DMLSql DML
Sql DML
Vikas Gupta
 
Components and Advantages of DBMS
Components and Advantages of DBMSComponents and Advantages of DBMS
Components and Advantages of DBMS
Shubham Joon
 
Sql commands
Sql commandsSql commands
Sql commands
Pooja Dixit
 
Database Keys
Database KeysDatabase Keys
Database Keys
Forrester High School
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database Design
Archit Saxena
 
Integrity constraints in dbms
Integrity constraints in dbmsIntegrity constraints in dbms
Integrity constraints in dbms
Vignesh Saravanan
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
Shrija Madhu
 
Database
DatabaseDatabase
Database
Bhandari Nawaraj
 
Database constraints
Database constraintsDatabase constraints
Database constraints
Khadija Parween
 
Unit 2 oracle9i
Unit 2  oracle9i Unit 2  oracle9i
Unit 2 oracle9i
DrkhanchanaR
 

Similar to Types of keys dbms (20)

DBMS_Keys.pdf
DBMS_Keys.pdfDBMS_Keys.pdf
DBMS_Keys.pdf
DianneParaase
 
Dbms keysppt
Dbms keyspptDbms keysppt
Dbms keysppt
ArunakumariAkula1
 
Keys.pptx
Keys.pptxKeys.pptx
Keys.pptx
revathi s
 
DBMS key topic Presentation slide 1.pptx
DBMS key topic Presentation slide 1.pptxDBMS key topic Presentation slide 1.pptx
DBMS key topic Presentation slide 1.pptx
sonudhakad173
 
Types Of Keys in DBMS
Types Of Keys in DBMSTypes Of Keys in DBMS
Types Of Keys in DBMS
PadamNepal1
 
computer-210809080138.pdf
computer-210809080138.pdfcomputer-210809080138.pdf
computer-210809080138.pdf
rahulsharma571283
 
Keys_in_DBMS_VALID_INFORMATION_IS_AVAILA
Keys_in_DBMS_VALID_INFORMATION_IS_AVAILAKeys_in_DBMS_VALID_INFORMATION_IS_AVAILA
Keys_in_DBMS_VALID_INFORMATION_IS_AVAILA
prashantkori7
 
key1.pdf
key1.pdfkey1.pdf
key1.pdf
ajajkhan16
 
DBMS-Keys , Attributes and Constraints.pptx
DBMS-Keys , Attributes and Constraints.pptxDBMS-Keys , Attributes and Constraints.pptx
DBMS-Keys , Attributes and Constraints.pptx
sajinis5
 
fundamentals-of-database.pptx hehehehehe
fundamentals-of-database.pptx hehehehehefundamentals-of-database.pptx hehehehehe
fundamentals-of-database.pptx hehehehehe
KrstineNicoleLaada
 
Keys in DBMS.pptx
Keys in DBMS.pptxKeys in DBMS.pptx
Keys in DBMS.pptx
Revathy V R
 
Key in DatabaseManagementSystem_engineering.pptx
Key in DatabaseManagementSystem_engineering.pptxKey in DatabaseManagementSystem_engineering.pptx
Key in DatabaseManagementSystem_engineering.pptx
snehavenkatt27
 
Presentation OF DBMS-2.pptx
Presentation OF DBMS-2.pptxPresentation OF DBMS-2.pptx
Presentation OF DBMS-2.pptx
ShumailaSajjad
 
DBMS VHGFGJKFHVGFJKHHFVHGFHBBVVHGVVHGVBVHG
DBMS VHGFGJKFHVGFJKHHFVHGFHBBVVHGVVHGVBVHGDBMS VHGFGJKFHVGFJKHHFVHGFHBBVVHGVVHGVBVHG
DBMS VHGFGJKFHVGFJKHHFVHGFHBBVVHGVVHGVBVHG
umeshchandrekanti123
 
B & c
B & cB & c
B & c
Vaibhav Kathuria
 
Databases - Unit 2.pdf
Databases - Unit 2.pdfDatabases - Unit 2.pdf
Databases - Unit 2.pdf
CynthiaAdzornu
 
Keys presentation
Keys presentationKeys presentation
Keys presentation
mubeenkiran
 
SQL_DBMS_KEYS.pptx
SQL_DBMS_KEYS.pptxSQL_DBMS_KEYS.pptx
SQL_DBMS_KEYS.pptx
rahulsharma571283
 
KEYS IN DBMS.pptx soap ui kkeys and eclipse id
KEYS IN DBMS.pptx soap ui kkeys and eclipse idKEYS IN DBMS.pptx soap ui kkeys and eclipse id
KEYS IN DBMS.pptx soap ui kkeys and eclipse id
LakshyaBaliyan2
 
Relational database Management system.pptx
Relational database Management system.pptxRelational database Management system.pptx
Relational database Management system.pptx
RevathiNCommerceCSCA
 
DBMS key topic Presentation slide 1.pptx
DBMS key topic Presentation slide 1.pptxDBMS key topic Presentation slide 1.pptx
DBMS key topic Presentation slide 1.pptx
sonudhakad173
 
Types Of Keys in DBMS
Types Of Keys in DBMSTypes Of Keys in DBMS
Types Of Keys in DBMS
PadamNepal1
 
Keys_in_DBMS_VALID_INFORMATION_IS_AVAILA
Keys_in_DBMS_VALID_INFORMATION_IS_AVAILAKeys_in_DBMS_VALID_INFORMATION_IS_AVAILA
Keys_in_DBMS_VALID_INFORMATION_IS_AVAILA
prashantkori7
 
DBMS-Keys , Attributes and Constraints.pptx
DBMS-Keys , Attributes and Constraints.pptxDBMS-Keys , Attributes and Constraints.pptx
DBMS-Keys , Attributes and Constraints.pptx
sajinis5
 
fundamentals-of-database.pptx hehehehehe
fundamentals-of-database.pptx hehehehehefundamentals-of-database.pptx hehehehehe
fundamentals-of-database.pptx hehehehehe
KrstineNicoleLaada
 
Keys in DBMS.pptx
Keys in DBMS.pptxKeys in DBMS.pptx
Keys in DBMS.pptx
Revathy V R
 
Key in DatabaseManagementSystem_engineering.pptx
Key in DatabaseManagementSystem_engineering.pptxKey in DatabaseManagementSystem_engineering.pptx
Key in DatabaseManagementSystem_engineering.pptx
snehavenkatt27
 
Presentation OF DBMS-2.pptx
Presentation OF DBMS-2.pptxPresentation OF DBMS-2.pptx
Presentation OF DBMS-2.pptx
ShumailaSajjad
 
DBMS VHGFGJKFHVGFJKHHFVHGFHBBVVHGVVHGVBVHG
DBMS VHGFGJKFHVGFJKHHFVHGFHBBVVHGVVHGVBVHGDBMS VHGFGJKFHVGFJKHHFVHGFHBBVVHGVVHGVBVHG
DBMS VHGFGJKFHVGFJKHHFVHGFHBBVVHGVVHGVBVHG
umeshchandrekanti123
 
Databases - Unit 2.pdf
Databases - Unit 2.pdfDatabases - Unit 2.pdf
Databases - Unit 2.pdf
CynthiaAdzornu
 
Keys presentation
Keys presentationKeys presentation
Keys presentation
mubeenkiran
 
KEYS IN DBMS.pptx soap ui kkeys and eclipse id
KEYS IN DBMS.pptx soap ui kkeys and eclipse idKEYS IN DBMS.pptx soap ui kkeys and eclipse id
KEYS IN DBMS.pptx soap ui kkeys and eclipse id
LakshyaBaliyan2
 
Relational database Management system.pptx
Relational database Management system.pptxRelational database Management system.pptx
Relational database Management system.pptx
RevathiNCommerceCSCA
 
Ad

More from Surkhab Shelly (18)

2020 sd college- internet of everyhing
2020 sd college- internet of everyhing2020 sd college- internet of everyhing
2020 sd college- internet of everyhing
Surkhab Shelly
 
Intro to computer
Intro to computerIntro to computer
Intro to computer
Surkhab Shelly
 
Intro to dbms
Intro to dbmsIntro to dbms
Intro to dbms
Surkhab Shelly
 
Architecture of dbms
Architecture of dbmsArchitecture of dbms
Architecture of dbms
Surkhab Shelly
 
Er model
Er modelEr model
Er model
Surkhab Shelly
 
Output devices
Output devicesOutput devices
Output devices
Surkhab Shelly
 
SQL
SQLSQL
SQL
Surkhab Shelly
 
Structured Query Language
Structured Query LanguageStructured Query Language
Structured Query Language
Surkhab Shelly
 
Types of secondary storage devices ppt
Types of secondary storage devices pptTypes of secondary storage devices ppt
Types of secondary storage devices ppt
Surkhab Shelly
 
Input devices
Input devicesInput devices
Input devices
Surkhab Shelly
 
FUNCTIONAL UNIT
FUNCTIONAL UNITFUNCTIONAL UNIT
FUNCTIONAL UNIT
Surkhab Shelly
 
TYPES OF MEMORY
TYPES OF MEMORYTYPES OF MEMORY
TYPES OF MEMORY
Surkhab Shelly
 
cyber crime
 cyber crime cyber crime
cyber crime
Surkhab Shelly
 
Fun ppt
Fun pptFun ppt
Fun ppt
Surkhab Shelly
 
Dbms
DbmsDbms
Dbms
Surkhab Shelly
 
Avl tree ppt
Avl tree pptAvl tree ppt
Avl tree ppt
Surkhab Shelly
 
7 foods-to-keep you healthy
7 foods-to-keep  you healthy7 foods-to-keep  you healthy
7 foods-to-keep you healthy
Surkhab Shelly
 
Dbms ppt
Dbms pptDbms ppt
Dbms ppt
Surkhab Shelly
 
Ad

Recently uploaded (20)

Pope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptxPope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptx
Martin M Flynn
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
The History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptxThe History of Kashmir Karkota Dynasty NEP.pptx
The History of Kashmir Karkota Dynasty NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
Pope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptxPope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptx
Martin M Flynn
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
Overview Well-Being and Creative Careers
Overview Well-Being and Creative CareersOverview Well-Being and Creative Careers
Overview Well-Being and Creative Careers
University of Amsterdam
 
All About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdfAll About the 990 Unlocking Its Mysteries and Its Power.pdf
All About the 990 Unlocking Its Mysteries and Its Power.pdf
TechSoup
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
Cultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptxCultivation Practice of Onion in Nepal.pptx
Cultivation Practice of Onion in Nepal.pptx
UmeshTimilsina1
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...Transform tomorrow: Master benefits analysis with Gen AI today webinar,  30 A...
Transform tomorrow: Master benefits analysis with Gen AI today webinar, 30 A...
Association for Project Management
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 

Types of keys dbms

  • 1. Types of Keys in Database Management System Presented By :- Mrs. Surkhab Shelly
  • 2. Why we have Keys in DB? • A Key is an attribute or a set of attributes in a relation that identifies a tuple (record) in a relation. • The keys are defined in a table to access or sequence the stored data quickly and smoothly. • They are also used to create relationship between different tables.
  • 3. Types of Keys in Database • 1. Primary Key • 2. Candidate Key • 3. Alternate Key • 4. Super Key • 5. Composite Key • 6. Foreign Key • 7. Unique Key
  • 4. Primary Key Employee EmployeeID EmployeeName SSN DeptID DOB • Which is Unique & Can’t be have NULL Value • The minimal set of attributes (or attribute) which can uniquely identify the rows (tuples) in a table is known as a primary key.Key Points about Primary Key • Primary key is use to identify each row uniquely in a table. • Primary key cannot have a NULL value. • Each table can have only one primary key.
  • 5. Candidate Key Employee EmployeeID EmployeeName SSN DeptID DOB • Are individual columns in a table that qualifies for uniqueness of each row/tuple. • A candidate key is an attribute or set of an attribute which can uniquely identify a tuple. • Here in Employee table EmployeeID& SSN areeligible for a Primary Key and thus are Candidate keys.
  • 6. Dr. Kamal Gulati Alternate Key Employee EmployeeID EmployeeName SSN DeptID DOB • Candidate column other the Primary column, like if EmployeeID is set for a PK then SSN would be the Alternate key.
  • 7. Super Key Employee EmployeeID EmployeeNam e SSN DeptID DOB • If you add any other Column / Attribute to a Primary Key then it become a Super Key, like EmployeeID + EmployeeName is a Super Key. • Super key stands for superset of a key. • The name of two employees can be the same, but their EMPLYEE_ID can't be the same. Hence, this combination can also be a key. The super key would be EMPLOYEE-ID, (EMPLOYEE_ID, EMPLOYEE-NAME), etc. • A super key is a set of one of more columns (attributes) to uniquely identify rows in a table.
  • 8. Dr. Kamal Gulati Composite Key Employee EmployeeID EmployeeName SSN DeptID DOB • If a table do have a single column that qualifies for a Candidate key, then you have to select 2 or more columns to make a row unique. • Like if there is no EmployeeID or SSN columns, then you can make EmployeeName + DateOfBirth (DOB) as Composite Primary Key. But still there can be a narrow chance of duplicate rows.
  • 9. Foreign Key Employee EmployeeID EmployeeName SSN DeptID DOB Department DeptID DeptName •A foreign key is a field in table which is generally a primary key from another table. •In other words, if we had a table A with a primary key X that linked to a table B where X was a field in B, then X would be a foreign key in B. •A foreign key is those keys which are used to define a relationship between two or more tables. •When we want to implement a relationship between two tables then we use the concept of foreign key. It is also known as referential integrity. We can create more than one foreign key per table
  • 11. Unique Key • Unique key is same as primary with the difference being the existence of null. • Unique key field allows one value as NULL value. Employee EmployeeID EmployeeName SSN EmailID DOB
  • 12. Practical Example • • Table R1. Let A,B,C,D,E are the attributes of this relation. A→BCDE (This means the attribute 'A' uniquely determines the other attributes B,C,D,E.) BC→ADE (This means the attributes 'BC' jointly determines all the other attributes A,D,E in the relation.) • Find the following: – Primary Key – Candidate Key – Super Key – Composite Key Table – R1 A B C D E
  • 13. Dr. Kamal Gulati Answers: •Primary Key: A •Candidate Key: A & BC •Super Key:A, BC, AE, AD & ABC •Composite Key: BC
  翻译: