SlideShare a Scribd company logo
1 of 18
DBMS KEYS
• A key in DBMS is an attribute or a set of attributes that help to uniquely identify a
tuple (or row) in a relation (or table). Keys are also used to establish relationships
between the different tables and columns of a relational database.
DBMS has Seven types of Keys as follows:
• Super Key
• Candidate Key
• Primary Key
• Alternate Key
• Unique Key
• Foreign Key
• Composite Key
SUPERKEY
A super key is a set of one or more than one column that can
be used to identify a record uniquely in a table.
A Super Key can contain one or more than one attributes.
Example: Primary key, Unique key, Alternate key are a subset
of Super Keys.
customer
The combination of “SSN” and “Name” or “SSN” alone is a super key of the
following entity set
customer.
Because:
The value of attributes “SSN” and “Name”, such as 558-36-1234 and
Susan, can uniquely identify that particular customer in customer entity set.
Customer-street
SSN
Customer-city
Customer-name
SUPER KEY
Candidate Key
A Candidate key is a subset of Super key but it is lacking any unnecessary
column that is not important to be used uniquely identify tuples of a table.
There can be multiple Candidate Keys in one table.
Each Candidate Key can work as a Primary Key.
Properties of Candidate Key…..
CANDIDATEKEY
• Example:
• (SSN, Name) is NOT a candidate key, because taking out “customer-name” still
leaves “SSN” which can uniquely identify an entity. “SSN” is a candidate key of
customer.
• Example: Both “SSN” and “License #” are candidate keys of Customer entity set.
customer
Customer-license
SSN
Customer-city
Customer-name
Overall, Super Key is the broadest unique identifier; Candidate Key is a
subset of Super Key; and Primary Key is a subset of Candidate Key.
In practice, we would first look for Super Keys. Then we look for Candidate
Keys based on experience and common sense.
If there is only one Candidate Key, it naturally will be designated as the
Primary Key.
If we find more than one Candidate Key, then we can designate any one of
them as Primary Key.
PRIMARY KEY
 The Primary Key is a set of one or more fields/columns of a table
that uniquely identify a record in a database table.
 Out of all the candidate keys if, there should be only one key that
can be used to retrieve unique tuples from the table. This candidate
key is called the "Primary Key".
Toqualifyasaprimarykeyfor anentity,anattribute musthave the
followingproperties:
It musthaveanon-null valuefor eachinstanceof the entity
Thevaluemustbe unique for eachinstanceof an entity
Thevaluesmustnot changeor becomenull during the life of eachentity instance
Properties Of Primary Keys....
PRIMARYKEY
An Alternate key is a key that can work as a primary key. Basically, it is a candidate
key that currently is not a primary key.
Every table of the database table can have multiple options for a primary key to be
configured but out of them, only one column can be set as the primary key. All the
keys which are not primary keys are called the alternate keys of that table.
Properties Of Alternate Keys....
ALTERNATE KEY
Example: In the below diagram RollNo and EnrollNo become Alternate Keys
when we define ID as the Primary Key.
Aunique key is a set of one or more fields/columns of a table that uniquely
identify a record in a database table.
It is like a Primary key but it can accept only one null value and it can not have
duplicate values.
Properties Of Unique Key….
UNIQUE KEY
When a primary key is created from a combination of 2 or more columns, the
primary key is called a composite key.
Each column may not be unique by itself within the database table but when
combined with the other column(s) in the composite key, the combination is
unique.
Properties Of Composite Key….
COMPOSITE KEY
Primaryand Foreignkeys are the most basic components on
which relational theory is based. Eachentity must have a
attribute or attributes, the primary key, whose values
uniquely identify each instance of the entity. Every child
entity must have an attribute, the foreign key, that
completes the association with the parent entity.
FOREIGN KEY
Foreign Keyis a field in a table that is the Primary keyin another table.
It can accept multiple nulls and duplicate values.
Every relationship in the model must be supported by a foreign key.
 A Foreign key is an attribute that completes a relationship by
identifying the parententity.
 Foreign keys provide a method for maintaining integrity in the
data(called referential integrity) and for navigating between different
instances of an entity.
Properties Of Foreign Key….
FOREIGN KEY
Example: We can have a DeptID column in the Employee table which is pointing
to a DeptID column in a department table where it is a primary key.
SQL_DBMS_KEYS.pptx

More Related Content

Similar to SQL_DBMS_KEYS.pptx

Types Of Keys in DBMS
Types Of Keys in DBMSTypes Of Keys in DBMS
Types Of Keys in DBMSPadamNepal1
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database ModelShishir Aryal
 
Intro to Data warehousing lecture 12
Intro to Data warehousing   lecture 12Intro to Data warehousing   lecture 12
Intro to Data warehousing lecture 12AnwarrChaudary
 
DBMS-Keys , Attributes and Constraints.pptx
DBMS-Keys , Attributes and Constraints.pptxDBMS-Keys , Attributes and Constraints.pptx
DBMS-Keys , Attributes and Constraints.pptxsajinis5
 
Keys in DBMS.pptx
Keys in DBMS.pptxKeys in DBMS.pptx
Keys in DBMS.pptxRevathy V R
 
Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)SURBHI SAROHA
 
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.pptxsonudhakad173
 
Types of keys in database | SQL
Types of keys in database | SQLTypes of keys in database | SQL
Types of keys in database | SQLSumit Pandey
 
DBMS Keys.pptx
DBMS Keys.pptxDBMS Keys.pptx
DBMS Keys.pptxAryanGour1
 
2.2 keys
2.2 keys2.2 keys
2.2 keysELIMENG
 
Keys in Database Management System
Keys in Database Management SystemKeys in Database Management System
Keys in Database Management SystemAnkit Rai
 

Similar to SQL_DBMS_KEYS.pptx (20)

Doc 20191022-wa0041
Doc 20191022-wa0041Doc 20191022-wa0041
Doc 20191022-wa0041
 
computer-210809080138.pdf
computer-210809080138.pdfcomputer-210809080138.pdf
computer-210809080138.pdf
 
Types Of Keys in DBMS
Types Of Keys in DBMSTypes Of Keys in DBMS
Types Of Keys in DBMS
 
key.pptx
key.pptxkey.pptx
key.pptx
 
Keys.pptx
Keys.pptxKeys.pptx
Keys.pptx
 
Keys used in database
Keys used in databaseKeys used in database
Keys used in database
 
DBMS_Keys.pdf
DBMS_Keys.pdfDBMS_Keys.pdf
DBMS_Keys.pdf
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database Model
 
Intro to Data warehousing lecture 12
Intro to Data warehousing   lecture 12Intro to Data warehousing   lecture 12
Intro to Data warehousing lecture 12
 
DBMS-Keys , Attributes and Constraints.pptx
DBMS-Keys , Attributes and Constraints.pptxDBMS-Keys , Attributes and Constraints.pptx
DBMS-Keys , Attributes and Constraints.pptx
 
DBMS Unit 2 ppt.ppt
DBMS Unit 2 ppt.pptDBMS Unit 2 ppt.ppt
DBMS Unit 2 ppt.ppt
 
B & c
B & cB & c
B & c
 
Keys in DBMS.pptx
Keys in DBMS.pptxKeys in DBMS.pptx
Keys in DBMS.pptx
 
Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)
 
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
 
Types of keys in database | SQL
Types of keys in database | SQLTypes of keys in database | SQL
Types of keys in database | SQL
 
Types of keys dbms
Types of keys dbmsTypes of keys dbms
Types of keys dbms
 
DBMS Keys.pptx
DBMS Keys.pptxDBMS Keys.pptx
DBMS Keys.pptx
 
2.2 keys
2.2 keys2.2 keys
2.2 keys
 
Keys in Database Management System
Keys in Database Management SystemKeys in Database Management System
Keys in Database Management System
 

Recently uploaded

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 

Recently uploaded (20)

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 

SQL_DBMS_KEYS.pptx

  • 2. • A key in DBMS is an attribute or a set of attributes that help to uniquely identify a tuple (or row) in a relation (or table). Keys are also used to establish relationships between the different tables and columns of a relational database. DBMS has Seven types of Keys as follows: • Super Key • Candidate Key • Primary Key • Alternate Key • Unique Key • Foreign Key • Composite Key
  • 3. SUPERKEY A super key is a set of one or more than one column that can be used to identify a record uniquely in a table. A Super Key can contain one or more than one attributes. Example: Primary key, Unique key, Alternate key are a subset of Super Keys.
  • 4. customer The combination of “SSN” and “Name” or “SSN” alone is a super key of the following entity set customer. Because: The value of attributes “SSN” and “Name”, such as 558-36-1234 and Susan, can uniquely identify that particular customer in customer entity set. Customer-street SSN Customer-city Customer-name SUPER KEY
  • 5. Candidate Key A Candidate key is a subset of Super key but it is lacking any unnecessary column that is not important to be used uniquely identify tuples of a table. There can be multiple Candidate Keys in one table. Each Candidate Key can work as a Primary Key. Properties of Candidate Key…..
  • 6. CANDIDATEKEY • Example: • (SSN, Name) is NOT a candidate key, because taking out “customer-name” still leaves “SSN” which can uniquely identify an entity. “SSN” is a candidate key of customer. • Example: Both “SSN” and “License #” are candidate keys of Customer entity set. customer Customer-license SSN Customer-city Customer-name
  • 7. Overall, Super Key is the broadest unique identifier; Candidate Key is a subset of Super Key; and Primary Key is a subset of Candidate Key. In practice, we would first look for Super Keys. Then we look for Candidate Keys based on experience and common sense. If there is only one Candidate Key, it naturally will be designated as the Primary Key. If we find more than one Candidate Key, then we can designate any one of them as Primary Key.
  • 8. PRIMARY KEY  The Primary Key is a set of one or more fields/columns of a table that uniquely identify a record in a database table.  Out of all the candidate keys if, there should be only one key that can be used to retrieve unique tuples from the table. This candidate key is called the "Primary Key".
  • 9. Toqualifyasaprimarykeyfor anentity,anattribute musthave the followingproperties: It musthaveanon-null valuefor eachinstanceof the entity Thevaluemustbe unique for eachinstanceof an entity Thevaluesmustnot changeor becomenull during the life of eachentity instance Properties Of Primary Keys.... PRIMARYKEY
  • 10. An Alternate key is a key that can work as a primary key. Basically, it is a candidate key that currently is not a primary key. Every table of the database table can have multiple options for a primary key to be configured but out of them, only one column can be set as the primary key. All the keys which are not primary keys are called the alternate keys of that table. Properties Of Alternate Keys.... ALTERNATE KEY
  • 11. Example: In the below diagram RollNo and EnrollNo become Alternate Keys when we define ID as the Primary Key.
  • 12. Aunique key is a set of one or more fields/columns of a table that uniquely identify a record in a database table. It is like a Primary key but it can accept only one null value and it can not have duplicate values. Properties Of Unique Key…. UNIQUE KEY
  • 13. When a primary key is created from a combination of 2 or more columns, the primary key is called a composite key. Each column may not be unique by itself within the database table but when combined with the other column(s) in the composite key, the combination is unique. Properties Of Composite Key…. COMPOSITE KEY
  • 14. Primaryand Foreignkeys are the most basic components on which relational theory is based. Eachentity must have a attribute or attributes, the primary key, whose values uniquely identify each instance of the entity. Every child entity must have an attribute, the foreign key, that completes the association with the parent entity.
  • 15. FOREIGN KEY Foreign Keyis a field in a table that is the Primary keyin another table. It can accept multiple nulls and duplicate values. Every relationship in the model must be supported by a foreign key.
  • 16.  A Foreign key is an attribute that completes a relationship by identifying the parententity.  Foreign keys provide a method for maintaining integrity in the data(called referential integrity) and for navigating between different instances of an entity. Properties Of Foreign Key…. FOREIGN KEY
  • 17. Example: We can have a DeptID column in the Employee table which is pointing to a DeptID column in a department table where it is a primary key.