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

More Related Content

What's hot (20)

Types Of Keys in DBMS
Types Of Keys in DBMSTypes Of Keys in DBMS
Types Of Keys in DBMS
 
Unit 5 composite datatypes
Unit 5  composite datatypesUnit 5  composite datatypes
Unit 5 composite datatypes
 
Keys in dbms
Keys in dbmsKeys in dbms
Keys in dbms
 
Slide 5 keys
Slide 5 keysSlide 5 keys
Slide 5 keys
 
Database language
Database languageDatabase language
Database language
 
Nested queries in database
Nested queries in databaseNested queries in database
Nested queries in database
 
Advanced SQL
Advanced SQLAdvanced SQL
Advanced SQL
 
DML Commands
DML CommandsDML Commands
DML Commands
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
 
Types of keys in dbms
Types of keys in dbmsTypes of keys in dbms
Types of keys in dbms
 
Sql Constraints
Sql ConstraintsSql Constraints
Sql Constraints
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
Database Keys & Relationship
Database Keys & RelationshipDatabase Keys & Relationship
Database Keys & Relationship
 
Trigger
TriggerTrigger
Trigger
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
 
Sql commands
Sql commandsSql commands
Sql commands
 
Oracle Database Trigger
Oracle Database TriggerOracle Database Trigger
Oracle Database Trigger
 
Intro to dbms
Intro to dbmsIntro to dbms
Intro to dbms
 

Similar to Types of keys dbms

Similar to Types of keys dbms (20)

Dbms keys
Dbms keysDbms keys
Dbms keys
 
DBMS_Keys.pdf
DBMS_Keys.pdfDBMS_Keys.pdf
DBMS_Keys.pdf
 
Dbms keysppt
Dbms keyspptDbms keysppt
Dbms keysppt
 
Keys.pptx
Keys.pptxKeys.pptx
Keys.pptx
 
Types of keys in database | SQL
Types of keys in database | SQLTypes of keys in database | SQL
Types of keys in database | SQL
 
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
 
computer-210809080138.pdf
computer-210809080138.pdfcomputer-210809080138.pdf
computer-210809080138.pdf
 
key1.pdf
key1.pdfkey1.pdf
key1.pdf
 
DBMS-Keys , Attributes and Constraints.pptx
DBMS-Keys , Attributes and Constraints.pptxDBMS-Keys , Attributes and Constraints.pptx
DBMS-Keys , Attributes and Constraints.pptx
 
Keys in DBMS.pptx
Keys in DBMS.pptxKeys in DBMS.pptx
Keys in DBMS.pptx
 
Key in DatabaseManagementSystem_engineering.pptx
Key in DatabaseManagementSystem_engineering.pptxKey in DatabaseManagementSystem_engineering.pptx
Key in DatabaseManagementSystem_engineering.pptx
 
Presentation OF DBMS-2.pptx
Presentation OF DBMS-2.pptxPresentation OF DBMS-2.pptx
Presentation OF DBMS-2.pptx
 
B & c
B & cB & c
B & c
 
Databases - Unit 2.pdf
Databases - Unit 2.pdfDatabases - Unit 2.pdf
Databases - Unit 2.pdf
 
Keys presentation
Keys presentationKeys presentation
Keys presentation
 
SQL_DBMS_KEYS.pptx
SQL_DBMS_KEYS.pptxSQL_DBMS_KEYS.pptx
SQL_DBMS_KEYS.pptx
 
Dbms keys
Dbms keysDbms keys
Dbms keys
 
Keys in DBMS
Keys in DBMSKeys in DBMS
Keys in DBMS
 
DBMS Keys.pptx
DBMS Keys.pptxDBMS Keys.pptx
DBMS Keys.pptx
 
Doc 20191022-wa0041
Doc 20191022-wa0041Doc 20191022-wa0041
Doc 20191022-wa0041
 

More from Surkhab Shelly (17)

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

Recently uploaded

How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 

Recently uploaded (20)

How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 

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
  • 10.
  • 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