SlideShare a Scribd company logo
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

Relational model
Relational modelRelational model
Relational model
SarithaDhanapal
 
Relational model
Relational modelRelational model
Relational model
Jihin Raju
 
Relational model
Relational modelRelational model
Relational model
Jihin Raju
 
Relational model
Relational modelRelational model
Relational model
Jihin Raju
 
Database keys
Database keysDatabase keys
Database keys
Rahul Mishra
 
Doc 20191022-wa0041
Doc 20191022-wa0041Doc 20191022-wa0041
Doc 20191022-wa0041
university of Gujrat, pakistan
 
Relational model
Relational modelRelational model
Relational model
Dabbal Singh Mahara
 
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
Md.Abu Sayed
 
Relational keys
Relational keysRelational keys
Relational keys
Sana2020
 
Relational model for Databases
Relational model for DatabasesRelational model for Databases
Relational model for Databases
Ramrao Desai
 

Similar to Types of keys (10)

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
 
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

BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball playEric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
enizeyimana36
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
mamunhossenbd75
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
wisnuprabawa3
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
University of Maribor
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 

Recently uploaded (20)

BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball playEric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
Eric Nizeyimana's document 2006 from gicumbi to ttc nyamata handball play
 
Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 

Types of keys