SlideShare a Scribd company logo
1 of 13
Key
DBMS
Prepared By: Bikash Sapkota
Deerwalk Ins. Of Technology
Kathmandu, Nepal
Introduction
 Keys(Name clearly define)
A key part of a relational database and a vital part of the structure of
a table. They ensure each record within a table can be uniquely
identified by one or a combination of fields within the table. They help
enforce integrity and help identify the relationship between tables.
Keys
 Super Key
 Candidate Key
 Primary Key
Super Key
 A Super key is any combination of fields within a table that uniquely
identifies each record within that table.
Book
Book ID Name Author
B1 Xyz A1
B2 ABC A1
B3 XYZ A2
B4 PQR A3
B5 RST A1
B6 ABC A3
Candidate Key
 Candidate key is a subset of super key
 A candidate key is a single field or the least combination of fields that
uniquely identifies each record in table
 The least combination of fields distinguishes a candidate key from a
super key.
 Every table must have at least one candidate
 Properties
 Unique
 Not null
 Contains minimum number of fields to ensure uniqueness
 Must uniquely identify each record in the table
Book ID Name Author
B1 XYZ A!
B2 ABC A1
B3 XYZ A2
B4 PQR A3
B5 RST A1
B6 ABC A3
Name BookId Author Name Author
Primary Key
 It is a candidate key
 Uniquely identify a specific instance of an entity
 Primary key cannot contain any Null value because we cannot
uniquely identify multiple Null values.
 Properties
 Stable
 Minimal
 Definitive
 Accessible
Book ID Name Author
B1 Xyz A!
B2 ABC A1
B3 XYZ A2
B4 PQR A3
B5 RST A1
B6 ABC A3
Book ID Name Author
 CREATE TABLE Persons
(
P_Id int NOT NULL PRIMARY KEY,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);
 CREATE TABLE Person
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
CONSTRAINT pk_PersonID PRIMARY KEY (P_Id,LastName)
);
Foreign Key
 Foreign key is a field in a relational table that matches the primary
key column of another table.
 It can be used to link two tables together
 CREATE TABLE supplier
 ( supplier_id numeric(10) not null,
 supplier_name varchar2(50) not null,
 contact_name varchar2(50),
 CONSTRAINT supplier_pk PRIMARY KEY (supplier_id)
 );
 CREATE TABLE products
 ( product_id numeric(10) not null,
 supplier_id numeric(10) not null,
 CONSTRAINT fk_supplier
 FOREIGN KEY (supplier_id)
 REFERENCES supplier(supplier_id)
 );
Remaining
Alternate Key
Remaining candidate key which are not selected as primary key
Composite Key
Primary key made up of more than one attribute

More Related Content

Viewers also liked

От SIEM к SOC дорогу осилит смотрящий
От SIEM к SOC дорогу осилит смотрящийОт SIEM к SOC дорогу осилит смотрящий
От SIEM к SOC дорогу осилит смотрящий
jet_information_security
 

Viewers also liked (13)

UX wireframes
UX wireframesUX wireframes
UX wireframes
 
Ekonomický týždenník Poštovej banky - 44. týždeň
Ekonomický týždenník Poštovej banky - 44. týždeňEkonomický týždenník Poštovej banky - 44. týždeň
Ekonomický týždenník Poštovej banky - 44. týždeň
 
Ekonomický týždenník Poštovej banky - 32. týždeň
Ekonomický týždenník Poštovej banky - 32. týždeňEkonomický týždenník Poštovej banky - 32. týždeň
Ekonomický týždenník Poštovej banky - 32. týždeň
 
10.hafta sunu
10.hafta sunu10.hafta sunu
10.hafta sunu
 
От SIEM к SOC дорогу осилит смотрящий
От SIEM к SOC дорогу осилит смотрящийОт SIEM к SOC дорогу осилит смотрящий
От SIEM к SOC дорогу осилит смотрящий
 
Reflections on teachingand more (1)
Reflections on teachingand more (1)Reflections on teachingand more (1)
Reflections on teachingand more (1)
 
Ekonomický týždenník Poštovej banky - 27. týždeň
Ekonomický týždenník Poštovej banky - 27. týždeňEkonomický týždenník Poštovej banky - 27. týždeň
Ekonomický týždenník Poštovej banky - 27. týždeň
 
Путешествие по Германии
Путешествие по ГерманииПутешествие по Германии
Путешествие по Германии
 
ИБ эпохи перемен
ИБ эпохи переменИБ эпохи перемен
ИБ эпохи перемен
 
TIK BAB 5
TIK BAB 5TIK BAB 5
TIK BAB 5
 
Can we share
Can we shareCan we share
Can we share
 
Stvorimo bolji internet zajedno rea i evelyn
Stvorimo bolji internet zajedno rea i evelynStvorimo bolji internet zajedno rea i evelyn
Stvorimo bolji internet zajedno rea i evelyn
 
Ekonomický týždenník Poštovej banky - 39. týždeň
Ekonomický týždenník Poštovej banky - 39. týždeňEkonomický týždenník Poštovej banky - 39. týždeň
Ekonomický týždenník Poštovej banky - 39. týždeň
 

Similar to Key (12)

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
 
oracle Sql constraint
oracle  Sql constraint oracle  Sql constraint
oracle Sql constraint
 
Relational database management system
Relational database management systemRelational database management system
Relational database management system
 
Create table
Create tableCreate table
Create table
 
key (1).pptx
key (1).pptxkey (1).pptx
key (1).pptx
 
Sql practise for beginners
Sql practise for beginnersSql practise for beginners
Sql practise for beginners
 
introdution concept on _ _ sql_basic.ppt
introdution concept on _ _ sql_basic.pptintrodution concept on _ _ sql_basic.ppt
introdution concept on _ _ sql_basic.ppt
 
Relational Model - An Introduction
Relational Model - An IntroductionRelational Model - An Introduction
Relational Model - An Introduction
 
Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)
 
Sql ch 12 - creating database
Sql ch 12 - creating databaseSql ch 12 - creating database
Sql ch 12 - creating database
 
Keys in Database
Keys in DatabaseKeys in Database
Keys in Database
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 

Key

  • 1. Key DBMS Prepared By: Bikash Sapkota Deerwalk Ins. Of Technology Kathmandu, Nepal
  • 2. Introduction  Keys(Name clearly define) A key part of a relational database and a vital part of the structure of a table. They ensure each record within a table can be uniquely identified by one or a combination of fields within the table. They help enforce integrity and help identify the relationship between tables.
  • 3. Keys  Super Key  Candidate Key  Primary Key
  • 4. Super Key  A Super key is any combination of fields within a table that uniquely identifies each record within that table.
  • 5. Book Book ID Name Author B1 Xyz A1 B2 ABC A1 B3 XYZ A2 B4 PQR A3 B5 RST A1 B6 ABC A3
  • 6. Candidate Key  Candidate key is a subset of super key  A candidate key is a single field or the least combination of fields that uniquely identifies each record in table  The least combination of fields distinguishes a candidate key from a super key.  Every table must have at least one candidate  Properties  Unique  Not null  Contains minimum number of fields to ensure uniqueness  Must uniquely identify each record in the table
  • 7. Book ID Name Author B1 XYZ A! B2 ABC A1 B3 XYZ A2 B4 PQR A3 B5 RST A1 B6 ABC A3 Name BookId Author Name Author
  • 8. Primary Key  It is a candidate key  Uniquely identify a specific instance of an entity  Primary key cannot contain any Null value because we cannot uniquely identify multiple Null values.  Properties  Stable  Minimal  Definitive  Accessible
  • 9. Book ID Name Author B1 Xyz A! B2 ABC A1 B3 XYZ A2 B4 PQR A3 B5 RST A1 B6 ABC A3 Book ID Name Author
  • 10.  CREATE TABLE Persons ( P_Id int NOT NULL PRIMARY KEY, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255) );  CREATE TABLE Person ( P_Id int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255), CONSTRAINT pk_PersonID PRIMARY KEY (P_Id,LastName) );
  • 11. Foreign Key  Foreign key is a field in a relational table that matches the primary key column of another table.  It can be used to link two tables together
  • 12.  CREATE TABLE supplier  ( supplier_id numeric(10) not null,  supplier_name varchar2(50) not null,  contact_name varchar2(50),  CONSTRAINT supplier_pk PRIMARY KEY (supplier_id)  );  CREATE TABLE products  ( product_id numeric(10) not null,  supplier_id numeric(10) not null,  CONSTRAINT fk_supplier  FOREIGN KEY (supplier_id)  REFERENCES supplier(supplier_id)  );
  • 13. Remaining Alternate Key Remaining candidate key which are not selected as primary key Composite Key Primary key made up of more than one attribute

Editor's Notes

  1. There are three main types of keys, candidate keys, primary keys and foreign keys. There is also an alternative key or secondary key that can be used, as the name suggests, as a secondary or alternative key to the primary key
  2. If 3 are super key then name and author are redundant key
  3. Cannot be reduced further