SlideShare a Scribd company logo
1 of 21
What is key?
A key is an attribute or a set of attributes in
a relation that identifies a tuple in a relation.
Types of keys
Alternate
Super
Types Of Keys
Super key
Super key is defined as set of one or more
attributes that uniquely identifies each record
within a table.
`
S. no.
Emp.
ID
Emp.
Name
Dept.
ID
Phone
no.
Salary Address
1 E101 Mohan D1 81234516 20000 Mathura
2 E102 Shyam D2 81452679 30000 Agra
3 E103 Rahul D3 81234516 40000 Vrindavan
4 E104 Amit D2 81625637 10000 Mathura
Example of super key:-
Super key
S. no., Emp. name, Dept. ID Emp. ID, Address
Super key
Candidate key
Candidate key is a set of one or more
attribute that allows us to uniquely
identify a tuple in a relation.
S. no.
Emp.
ID
Emp.
Name
Dept.
ID
Phone
no.
Salary Address
1 E101 Mohan D1 8123451 20000 Mathura
2 E102 Shyam D2 8145267 30000 Agra
3 E103 Rahul D3 8123451 40000 Vrindavan
4 E104 Amit D2 8162563 10000 Mathura
Example of candidate key:-
Candidate key
Primary key
A primary key is a candidate key
that is selected by the database
designer to identify tuples
uniquely in a relation.
Important points about a primary key
A relation can have only one primary
key.
Each value in primary key attribute
must be unique.
Primary key can not contain null values.
S. no.
Emp.
ID
Emp.
Name
Dept.
ID
Phone
no.
Salary Address
1 E101 Mohan D1 8123451 20000 Mathura
2 E102 Shyam D2 8145267 30000 Agra
3 E103 Rahul D3 8123451 40000 Vrindavan
4 E104 Amit D2 8162563 10000 Mathura
Example of primary key:-
Primary key
Alternate key
The candidate key which are not
selected for primary key are
known as alternate key.
S. no. Emp. ID
Emp.
Name
Dpt.
Name
Ph. no. Salary Address
1 E101 Mohan D1 81234 2000 MTR
2 E102 Shyam D2 81452 3000 Agra
3 E103 Rahul D3 81234 4000 VBN
4 E104 Amit D2 81625 1000 MTR
Example of alternate key:-
Alternate key
S. No. Emp. ID
Emp. ID S. No.
Primary key Alternate key
Candidate key
Composite key
A primary key that consists of two or
more attributes is known as
composite key.
p
S. no.
Emp.
ID
Emp.
Name
Dept.
ID
Phone
no.
Salar
y
Address
1 E101 Mohan D1 8123451 20000 Mathura
2 E102 Shyam D2 8145267 30000 Agra
3 E103 Rahul D1 8123451 40000 Vrindavan
4 E104 Amit D2 8162563 10000 Mathura
Example of composite key:-
Composite key
S. No. , Emp. ID Primary key
Foreign key
A foreign key is an attribute or set of
attributes in a relation whose values
match a primary key in another
relation.
S.
no.
Emp.
ID
Emp.
Name
Dep
t.
ID
Phone
no.
Salar
y
Addr
ess
1 E101 Mohan D1 812345 20000 MTR
2 E102 Shyam D2 817172 30000 Agra
3 E103 Rahul D3 451617 40000 LCW
4 E104 Amit D2 563783 10000 MTR
Example of foreign key:-
Dept. ID
Dept.
Name Address
D1 Civil MTR
D2 M.E. LCW
D3 C.S. MTR
Foreign key Primary key
S.
No.
ID
Roll
no.
Nam
e
Enroll
no.
Addre
ss
Dept.
ID
1 ID1 6031 Ram AX10 MTR D1
2 ID2 6032 Anil AX11 VBN D1
3 ID3 6033 Amit AX12 MTR D2
4 ID4 6034 Ravi AX13 LCK D2
Example of all types of keys
Dept. ID Name Address
D1 IT MTR
D2 ME MTR
D3 CS MTR
Foreign key
Primary key
Primary key Alternate key
Candidate key Super key
Types of keys
Types of keys
Types of keys

More Related Content

Similar to Types of keys (11)

Relational model
Relational modelRelational model
Relational model
 
Relational model
Relational modelRelational model
Relational model
 
Relational model
Relational modelRelational model
Relational model
 
Relational model
Relational modelRelational model
Relational model
 
Module 2_Relational Algebra.pptx
Module 2_Relational Algebra.pptxModule 2_Relational Algebra.pptx
Module 2_Relational Algebra.pptx
 
Database keys
Database keysDatabase keys
Database keys
 
Doc 20191022-wa0041
Doc 20191022-wa0041Doc 20191022-wa0041
Doc 20191022-wa0041
 
Relational model
Relational modelRelational model
Relational model
 
Database management systems cs403 power point slides lecture 08
Database management systems   cs403 power point slides lecture 08Database management systems   cs403 power point slides lecture 08
Database management systems cs403 power point slides lecture 08
 
Relational keys
Relational keysRelational keys
Relational keys
 
Relational model for Databases
Relational model for DatabasesRelational model for Databases
Relational model for Databases
 

Recently uploaded

1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
AldoGarca30
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To Curves
 
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...Max. shear stress theory-Maximum Shear Stress Theory ​  Maximum Distortional ...
Max. shear stress theory-Maximum Shear Stress Theory ​ Maximum Distortional ...
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdf
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Electromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxElectromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptx
 
Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 

Types of keys