SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Mais procurados (20)

DBMS: Types of keys
DBMS:  Types of keysDBMS:  Types of keys
DBMS: Types of keys
 
Database
DatabaseDatabase
Database
 
Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Constraints In Sql
Constraints In SqlConstraints In Sql
Constraints In Sql
 
Databases: Normalisation
Databases: NormalisationDatabases: Normalisation
Databases: Normalisation
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Sql Constraints
Sql ConstraintsSql Constraints
Sql Constraints
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
Trigger
TriggerTrigger
Trigger
 
Sql join
Sql  joinSql  join
Sql join
 
Relational model
Relational modelRelational model
Relational model
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database Model
 
Database Relationships
Database RelationshipsDatabase Relationships
Database Relationships
 
Database
DatabaseDatabase
Database
 
Data Models
Data ModelsData Models
Data Models
 
Create table
Create tableCreate table
Create table
 
Normal forms
Normal formsNormal forms
Normal forms
 
Database Keys & Relationship
Database Keys & RelationshipDatabase Keys & Relationship
Database Keys & Relationship
 

Semelhante a Types of keys dbms

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

Mais de 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
 
Intro to computer
Intro to computerIntro to computer
Intro to computer
 
Intro to dbms
Intro to dbmsIntro to dbms
Intro to dbms
 
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
 

Último

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
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
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
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
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 

Último (20)

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
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
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
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...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 

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