SlideShare uma empresa Scribd logo
1 de 32
DBMS KEYS
9/26/2022 1
CA-1
TEST NAME:
K21SB-CA1-INT306
9/26/2022 2
DBMS Keys
9/26/2022 3
Def- DBMS Key
• KEYS in DBMS is an attribute or set of attributes which helps you to identify a
row(tuple) in a relation(table).
9/26/2022 4
• In the above-given example, employee ID is a primary key
because it uniquely identifies an employee record.
• In this table, no other employee can have the same employee
ID.
9/26/2022 5
Why we need a Key?
Here are some reasons for using sql key in the DBMS system.
– Keys help you to identify any row of data in a table. In a real-world
application, a table could contain thousands of records. Moreover, the
records could be duplicated. Keys ensure that you can uniquely identify a
table record despite these challenges.
– Allows you to establish a relationship between and identify the relation
between tables
– Help you to enforce identity and integrity in the relationship.
9/26/2022 6
Types of Keys in Database Management System
• Super Key - A super key is a group of single or multiple keys which
identifies rows in a table.
• Primary Key - is a column or group of columns in a table that
uniquely identify every row in that table.
• Candidate Key - is a set of attributes that uniquely identify tuples in
a table. Candidate Key is a super key with no repeated attributes.
• Alternate Key - is a column or group of columns in a table that
uniquely identify every row in that table.
• Foreign Key - is a column that creates a relationship between two
tables. The purpose of Foreign keys is to maintain data integrity
and allow navigation between two different instances of an entity.
9/26/2022 7
Types of Keys in Database Management
System
• Compound Key - has two or more attributes that allow you to uniquely
recognize a specific record. It is possible that each column may not be
unique by itself within the database.
• Composite Key - COMPOSITE KEY is a combination of two or more
columns that uniquely identify rows in a table
• Surrogate Key - An artificial key which aims to uniquely identify each record
is called a surrogate key. These kind of key are unique because they are
created when you don't have any natural primary key.
9/26/2022 8
What is the Super key?
• A superkey is a group of single or multiple keys which identifies rows in a
table. A Super key may have additional attributes that are not needed for
unique identification.
• In the above-given example, EmpSSN and EmpNum name are superkeys.
9/26/2022 9
What is a Primary Key?
• PRIMARY KEY is a column or group of columns in a table that
uniquely identify every row in that table. The Primary Key can't be a
duplicate meaning the same value can't appear more than once in
the table. A table cannot have more than one primary key.
• Rules for defining Primary key:
– Two rows can't have the same primary key value
– It must for every row to have a primary key value.
– The primary key field cannot be null.
– The value in a primary key column can never be modified or updated if
any foreign key refers to that primary key.
9/26/2022 10
9/26/2022 11
What is a Candidate Key?
• CANDIDATE KEY is a set of attributes that uniquely identify tuples in a table.
Candidate Key is a super key with no repeated attributes.
• The Primary key should be selected from the candidate keys.
• Every table must have at least a single candidate key.
• A table can have multiple candidate keys but only a single primary key.
• Properties of Candidate key:
– It must contain unique values
– Candidate key may have multiple attributes
– Must not contain null values
– It should contain minimum fields to ensure uniqueness
– Uniquely identify each record in a table
9/26/2022 12
9/26/2022 13
What is the Alternate key?
• ALTERNATE KEYS is a column or group of columns in a table
that uniquely identify every row in that table.
• A table can have multiple choices for a primary key but only one
can be set as the primary key.
• All the keys which are not primary key are called an Alternate
Key.
9/26/2022 14
9/26/2022 15
9/26/2022 16
What is the Foreign key?
• FOREIGN KEY is a column that creates a relationship between two tables.
• The purpose of Foreign keys is to maintain data integrity and allow
navigation between two different instances of an entity.
• It acts as a cross-reference between two tables as it references the primary
key of another table.
9/26/2022 17
9/26/2022
18
9/26/2022 19
What is the Compound key?
• COMPOUND KEY has two or more attributes that allow you to uniquely
recognize a specific record.
• It is possible that each column may not be unique by itself within the
database. However, when combined with the other column or columns the
combination of composite keys become unique.
• The purpose of the compound key in database is to uniquely identify each
record in the table.
9/26/2022 20
9/26/2022 21
What is the Composite key?
• COMPOSITE KEY is a combination of two or more columns that uniquely
identify rows in a table. The combination of columns guarantees uniqueness,
though individually uniqueness is not guaranteed. Hence, they are combined
to uniquely identify records in a table.
• The difference between compound and the composite key is that any
part of the compound key can be a foreign key, but the composite key may or
maybe not a part of the foreign key.
9/26/2022 22
What is a Surrogate key?
• SURROGATE KEYS is An artificial key which aims to uniquely identify each
record is called a surrogate key.
• This kind of partial key in dbms is unique because it is created when you
don't have any natural primary key.
• They do not lend any meaning to the data in the table.
• Surrogate key is usually an integer.
• A surrogate key is a value generated right before the record is inserted into a
table.
9/26/2022 23
9/26/2022 24
9/26/2022
25
9/26/2022
26
9/26/2022
27
9/26/2022
28
9/26/2022
29
9/26/2022
30
9/26/2022
31
Summary
• A key in SQL is an attribute or set of attributes which helps you to identify a row(tuple) in a
relation(table)
• DBMS keys allow you to establish a relationship between and identify the relation between
tables
• Seven Types of DBMS keys are Super, Primary, Candidate, Alternate, Foreign, Compound,
Composite, and Surrogate Key.
• A super key is a group of single or multiple keys which identifies rows in a table.
• A column or group of columns in a table which helps us to uniquely identifies every row in
that table is called a primary key
• All the keys which are not primary key are called an alternate key
• A super key with no repeated attribute is called candidate key
• A compound key is a key which has many fields which allow you to uniquely recognize a
specific record
• A key which has multiple attributes to uniquely identify rows in a table is called a composite
key
• An artificial key which aims to uniquely identify each record is called a surrogate key
• Primary Key never accept null values while a foreign key may accept multiple null values.
9/26/2022 32

Mais conteúdo relacionado

Semelhante a DBMS Keys.pptx

Semelhante a DBMS Keys.pptx (20)

Keys used in database
Keys used in databaseKeys used in database
Keys used in database
 
Relational database management system
Relational database management systemRelational database management system
Relational database management system
 
Chapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelChapter-5 The Relational Data Model
Chapter-5 The Relational Data Model
 
DBMS_Keys.pdf
DBMS_Keys.pdfDBMS_Keys.pdf
DBMS_Keys.pdf
 
SQL_DBMS_KEYS.pptx
SQL_DBMS_KEYS.pptxSQL_DBMS_KEYS.pptx
SQL_DBMS_KEYS.pptx
 
Types of keys dbms
Types of keys dbmsTypes of keys dbms
Types of keys dbms
 
Types of keys in database | SQL
Types of keys in database | SQLTypes of keys in database | SQL
Types of keys in database | SQL
 
V35 keys-c
V35  keys-cV35  keys-c
V35 keys-c
 
Sql introduction
Sql introductionSql introduction
Sql introduction
 
SQL
SQLSQL
SQL
 
5. relational structure
5. relational structure5. relational structure
5. relational structure
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database Model
 
Introduction of sql server indexing
Introduction of sql server indexingIntroduction of sql server indexing
Introduction of sql server indexing
 
Keys presentation
Keys presentationKeys presentation
Keys presentation
 
Introduction of DBMS
Introduction of DBMSIntroduction of DBMS
Introduction of DBMS
 
DBMS
DBMSDBMS
DBMS
 
Sql
SqlSql
Sql
 
Types of keys in dbms
Types of keys in dbmsTypes of keys in dbms
Types of keys in dbms
 
demo2.ppt
demo2.pptdemo2.ppt
demo2.ppt
 
Understanding Entity Relationship Models
Understanding Entity Relationship ModelsUnderstanding Entity Relationship Models
Understanding Entity Relationship Models
 

Último

Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniquesugginaramesh
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 

Último (20)

Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniques
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 

DBMS Keys.pptx

  • 4. Def- DBMS Key • KEYS in DBMS is an attribute or set of attributes which helps you to identify a row(tuple) in a relation(table). 9/26/2022 4
  • 5. • In the above-given example, employee ID is a primary key because it uniquely identifies an employee record. • In this table, no other employee can have the same employee ID. 9/26/2022 5
  • 6. Why we need a Key? Here are some reasons for using sql key in the DBMS system. – Keys help you to identify any row of data in a table. In a real-world application, a table could contain thousands of records. Moreover, the records could be duplicated. Keys ensure that you can uniquely identify a table record despite these challenges. – Allows you to establish a relationship between and identify the relation between tables – Help you to enforce identity and integrity in the relationship. 9/26/2022 6
  • 7. Types of Keys in Database Management System • Super Key - A super key is a group of single or multiple keys which identifies rows in a table. • Primary Key - is a column or group of columns in a table that uniquely identify every row in that table. • Candidate Key - is a set of attributes that uniquely identify tuples in a table. Candidate Key is a super key with no repeated attributes. • Alternate Key - is a column or group of columns in a table that uniquely identify every row in that table. • Foreign Key - is a column that creates a relationship between two tables. The purpose of Foreign keys is to maintain data integrity and allow navigation between two different instances of an entity. 9/26/2022 7
  • 8. Types of Keys in Database Management System • Compound Key - has two or more attributes that allow you to uniquely recognize a specific record. It is possible that each column may not be unique by itself within the database. • Composite Key - COMPOSITE KEY is a combination of two or more columns that uniquely identify rows in a table • Surrogate Key - An artificial key which aims to uniquely identify each record is called a surrogate key. These kind of key are unique because they are created when you don't have any natural primary key. 9/26/2022 8
  • 9. What is the Super key? • A superkey is a group of single or multiple keys which identifies rows in a table. A Super key may have additional attributes that are not needed for unique identification. • In the above-given example, EmpSSN and EmpNum name are superkeys. 9/26/2022 9
  • 10. What is a Primary Key? • PRIMARY KEY is a column or group of columns in a table that uniquely identify every row in that table. The Primary Key can't be a duplicate meaning the same value can't appear more than once in the table. A table cannot have more than one primary key. • Rules for defining Primary key: – Two rows can't have the same primary key value – It must for every row to have a primary key value. – The primary key field cannot be null. – The value in a primary key column can never be modified or updated if any foreign key refers to that primary key. 9/26/2022 10
  • 12. What is a Candidate Key? • CANDIDATE KEY is a set of attributes that uniquely identify tuples in a table. Candidate Key is a super key with no repeated attributes. • The Primary key should be selected from the candidate keys. • Every table must have at least a single candidate key. • A table can have multiple candidate keys but only a single primary key. • Properties of Candidate key: – It must contain unique values – Candidate key may have multiple attributes – Must not contain null values – It should contain minimum fields to ensure uniqueness – Uniquely identify each record in a table 9/26/2022 12
  • 14. What is the Alternate key? • ALTERNATE KEYS is a column or group of columns in a table that uniquely identify every row in that table. • A table can have multiple choices for a primary key but only one can be set as the primary key. • All the keys which are not primary key are called an Alternate Key. 9/26/2022 14
  • 17. What is the Foreign key? • FOREIGN KEY is a column that creates a relationship between two tables. • The purpose of Foreign keys is to maintain data integrity and allow navigation between two different instances of an entity. • It acts as a cross-reference between two tables as it references the primary key of another table. 9/26/2022 17
  • 20. What is the Compound key? • COMPOUND KEY has two or more attributes that allow you to uniquely recognize a specific record. • It is possible that each column may not be unique by itself within the database. However, when combined with the other column or columns the combination of composite keys become unique. • The purpose of the compound key in database is to uniquely identify each record in the table. 9/26/2022 20
  • 22. What is the Composite key? • COMPOSITE KEY is a combination of two or more columns that uniquely identify rows in a table. The combination of columns guarantees uniqueness, though individually uniqueness is not guaranteed. Hence, they are combined to uniquely identify records in a table. • The difference between compound and the composite key is that any part of the compound key can be a foreign key, but the composite key may or maybe not a part of the foreign key. 9/26/2022 22
  • 23. What is a Surrogate key? • SURROGATE KEYS is An artificial key which aims to uniquely identify each record is called a surrogate key. • This kind of partial key in dbms is unique because it is created when you don't have any natural primary key. • They do not lend any meaning to the data in the table. • Surrogate key is usually an integer. • A surrogate key is a value generated right before the record is inserted into a table. 9/26/2022 23
  • 32. Summary • A key in SQL is an attribute or set of attributes which helps you to identify a row(tuple) in a relation(table) • DBMS keys allow you to establish a relationship between and identify the relation between tables • Seven Types of DBMS keys are Super, Primary, Candidate, Alternate, Foreign, Compound, Composite, and Surrogate Key. • A super key is a group of single or multiple keys which identifies rows in a table. • A column or group of columns in a table which helps us to uniquely identifies every row in that table is called a primary key • All the keys which are not primary key are called an alternate key • A super key with no repeated attribute is called candidate key • A compound key is a key which has many fields which allow you to uniquely recognize a specific record • A key which has multiple attributes to uniquely identify rows in a table is called a composite key • An artificial key which aims to uniquely identify each record is called a surrogate key • Primary Key never accept null values while a foreign key may accept multiple null values. 9/26/2022 32