SlideShare a Scribd company logo
3
Most read
10
Most read
11
Most read
“TYPES OF KEYS IN
DATABASE”
PRESENTED BY:
DARSHAN HINGU
OBJECTIVES
 WHAT IS KEY?
 Super Key
 Primary Key
 Candidate Key
 Alternate Key
 Foreign Key
WHAT IS KEY?
 Keys are very important part of Relational database model.
 To maintain data integrity (that is data should be correct and in well
formed) we use concept of keys.
 It is used for identifying unique rows from table.
 They are used to establish and identify relationships between tables.
SUPER KEY
 A super key is any combination of columns within a table that uniquely identifies
each record within that table.
 As an example, a table used to store customer master details could contain
columns such as:
 Customer name
 Customer ID
 Social Security number (SSN)
 Address
 Date of birth
 A certain set of columns may be extracted and guaranteed unique to each
customer. Examples of super keys are as follows:
 Name+SSN+DOB
 ID+Name+SSN
 All keys are Super key but not vice versa.
PRIMARY KEY
 A primary key is a column in a table that uniquely identifies the rows in that
table.
 The data values placed in the primary key column must be unique to each
row; no duplicates can be used.
 Nulls are not allowed in primary key columns.
 For example, in the table below, CustomerNo, which displays the ID number
assigned to different customers, is the primary key.
 CREATE TABLE CUSTOMER
( CustomerNO int NOT NULL PRIMARY KEY,
FirstName varchar(20),
LastName varchar(20)
);
CustomerNo FirstName LastName
1 Sally Thompson
2 Sally Henderson
3 Harry Henderson
4 Sandra Wellington
CANDIDATE KEY
 There can be more than one candidate keys for a table.
 A candidate key of a relation is a minimal super key for that relation.
 A candidate key can be a combination of more than one columns.
 A Candidate Key is a set of one or more columns that can identify a
record uniquely in a table. There can be multiple Candidate Keys in one
table.
 Candidate keys are selected from the set of super keys, the only thing we
take care while selecting candidate key is: It should not have any
redundant attributes.
 A primary key is being selected from the group of candidate keys.
 The value of Candidate Key is non-null for every tuple.
ALTERNATE KEY
 Alternate keys are candidate keys that are not selected as primary key.
 Alternate key is also called “Secondary Key”.
 If any table have more than one candidate key, then after choosing
primary key from those candidate key, rest of candidate keys are known
as an alternate key of that table.
FOREIGN KEY
 Foreign key are those keys which is used to define relationship between
two tables.
 Foreign key are columns that point to primary key columns in other
database tables.
 It can accept multiple null, duplicate values.
 It is also known as referential integrity.
 --Course Table
CREATE TABLE course
(
courseid NUMBER(10) NOT NULL PRIMARY KEY, --primary key
CourseName varchar2(10) NOT NULL,
) ;
--Student Table
CREATE TABLE Student
(
studentId NUMBER(10) NOT NULL PRIMARY KEY, --primary key
firstName varchar2(10) NOT NULL,
lastName varchar2(10) NOT NULL,
courseid NUMBER(10) REFERENCES course(courseid) --foreign key
) ;
Example : We can have a courseid column in the Student table which is pointing to courseid
column in a course table where it a primary key.
Types of keys in dbms
RELATIONSHIP BETWEEN KEYS
Types of keys in dbms
THAN
KYOU
Ad

Recommended

DBMS Keys
DBMS Keys
Tarun Maheshwari
 
Data Base Management System.pdf
Data Base Management System.pdf
TENZING LHADON
 
Database Keys
Database Keys
Forrester High School
 
Types Of Keys in DBMS
Types Of Keys in DBMS
PadamNepal1
 
Entity Relationship Model
Entity Relationship Model
Slideshare
 
DBMS: Types of keys
DBMS: Types of keys
Bharati Ugale
 
The Relational Model
The Relational Model
Bhandari Nawaraj
 
Types of keys in database management system by Dr. Kamal Gulati
Types of keys in database management system by Dr. Kamal Gulati
Amity University | FMS - DU | IMT | Stratford University | KKMI International Institute | AIMA | DTU
 
DATABASE CONSTRAINTS
DATABASE CONSTRAINTS
sunanditaAnand
 
Database Triggers
Database Triggers
Aliya Saldanha
 
Joins in SQL
Joins in SQL
Vigneshwaran Sankaran
 
The Relational Database Model
The Relational Database Model
Shishir Aryal
 
Relational Data Model Introduction
Relational Data Model Introduction
Nishant Munjal
 
Relational model
Relational model
Dabbal Singh Mahara
 
Sql commands
Sql commands
Pooja Dixit
 
Key and its different types
Key and its different types
Umair Shakir
 
Dbms keys
Dbms keys
RUpaliLohar
 
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Biplap Bhattarai
 
joins in database
joins in database
Sultan Arshad
 
Types of keys dbms
Types of keys dbms
Surkhab Shelly
 
Aggregate functions
Aggregate functions
sinhacp
 
Integrity Constraints
Integrity Constraints
Megha yadav
 
SQL Joins.pptx
SQL Joins.pptx
Ankit Rai
 
Dbms relational model
Dbms relational model
Chirag vasava
 
Database keys
Database keys
Rahul Mishra
 
Trigger
Trigger
VForce Infotech
 
Integrity Constraints
Integrity Constraints
madhav bansal
 
Database Normalization
Database Normalization
Arun Sharma
 
What are Database keys in Database System
What are Database keys in Database System
punjabcollege8685
 
What are Database Keys in Database System
What are Database Keys in Database System
punjabcollege8685
 

More Related Content

What's hot (20)

DATABASE CONSTRAINTS
DATABASE CONSTRAINTS
sunanditaAnand
 
Database Triggers
Database Triggers
Aliya Saldanha
 
Joins in SQL
Joins in SQL
Vigneshwaran Sankaran
 
The Relational Database Model
The Relational Database Model
Shishir Aryal
 
Relational Data Model Introduction
Relational Data Model Introduction
Nishant Munjal
 
Relational model
Relational model
Dabbal Singh Mahara
 
Sql commands
Sql commands
Pooja Dixit
 
Key and its different types
Key and its different types
Umair Shakir
 
Dbms keys
Dbms keys
RUpaliLohar
 
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Biplap Bhattarai
 
joins in database
joins in database
Sultan Arshad
 
Types of keys dbms
Types of keys dbms
Surkhab Shelly
 
Aggregate functions
Aggregate functions
sinhacp
 
Integrity Constraints
Integrity Constraints
Megha yadav
 
SQL Joins.pptx
SQL Joins.pptx
Ankit Rai
 
Dbms relational model
Dbms relational model
Chirag vasava
 
Database keys
Database keys
Rahul Mishra
 
Trigger
Trigger
VForce Infotech
 
Integrity Constraints
Integrity Constraints
madhav bansal
 
Database Normalization
Database Normalization
Arun Sharma
 

Similar to Types of keys in dbms (20)

What are Database keys in Database System
What are Database keys in Database System
punjabcollege8685
 
What are Database Keys in Database System
What are Database Keys in Database System
punjabcollege8685
 
Keys in dbms(UNIT 2)
Keys in dbms(UNIT 2)
Dr. SURBHI SAROHA
 
Presentation OF DBMS-2.pptx
Presentation OF DBMS-2.pptx
ShumailaSajjad
 
computer-210809080138.pdf
computer-210809080138.pdf
rahulsharma571283
 
Dbms keysppt
Dbms keysppt
ArunakumariAkula1
 
Keys_in_DBMS_VALID_INFORMATION_IS_AVAILA
Keys_in_DBMS_VALID_INFORMATION_IS_AVAILA
prashantkori7
 
DBMS key topic Presentation slide 1.pptx
DBMS key topic Presentation slide 1.pptx
sonudhakad173
 
Keys.pptx
Keys.pptx
revathi s
 
Keys used in database
Keys used in database
university of Gujrat, pakistan
 
Keys in Database
Keys in Database
A. S. M. Shafi
 
Keys in SQL.........................pptx
Keys in SQL.........................pptx
ejazayesha485
 
Copy of Templates ............. (1).pptx
Copy of Templates ............. (1).pptx
ejazayesha485
 
Copy of Templates & Apps............................. (1).pptx
Copy of Templates & Apps............................. (1).pptx
ejazayesha485
 
relational data model in RDBMS USING KEYS.pptx
relational data model in RDBMS USING KEYS.pptx
urvashipundir04
 
relational data model In rdbms keys.pptx
relational data model In rdbms keys.pptx
urvashipundir04
 
relational data model in DBMS AND KEYS.pptx
relational data model in DBMS AND KEYS.pptx
urvashipundir04
 
A Presentation of Types of Keys in RDBMS.pptx
A Presentation of Types of Keys in RDBMS.pptx
harman6895ala
 
key (1).pptx
key (1).pptx
KAnurag2
 
DBMS VHGFGJKFHVGFJKHHFVHGFHBBVVHGVVHGVBVHG
DBMS VHGFGJKFHVGFJKHHFVHGFHBBVVHGVVHGVBVHG
umeshchandrekanti123
 
What are Database keys in Database System
What are Database keys in Database System
punjabcollege8685
 
What are Database Keys in Database System
What are Database Keys in Database System
punjabcollege8685
 
Presentation OF DBMS-2.pptx
Presentation OF DBMS-2.pptx
ShumailaSajjad
 
Keys_in_DBMS_VALID_INFORMATION_IS_AVAILA
Keys_in_DBMS_VALID_INFORMATION_IS_AVAILA
prashantkori7
 
DBMS key topic Presentation slide 1.pptx
DBMS key topic Presentation slide 1.pptx
sonudhakad173
 
Keys in SQL.........................pptx
Keys in SQL.........................pptx
ejazayesha485
 
Copy of Templates ............. (1).pptx
Copy of Templates ............. (1).pptx
ejazayesha485
 
Copy of Templates & Apps............................. (1).pptx
Copy of Templates & Apps............................. (1).pptx
ejazayesha485
 
relational data model in RDBMS USING KEYS.pptx
relational data model in RDBMS USING KEYS.pptx
urvashipundir04
 
relational data model In rdbms keys.pptx
relational data model In rdbms keys.pptx
urvashipundir04
 
relational data model in DBMS AND KEYS.pptx
relational data model in DBMS AND KEYS.pptx
urvashipundir04
 
A Presentation of Types of Keys in RDBMS.pptx
A Presentation of Types of Keys in RDBMS.pptx
harman6895ala
 
key (1).pptx
key (1).pptx
KAnurag2
 
DBMS VHGFGJKFHVGFJKHHFVHGFHBBVVHGVVHGVBVHG
DBMS VHGFGJKFHVGFJKHHFVHGFHBBVVHGVVHGVBVHG
umeshchandrekanti123
 
Ad

Recently uploaded (20)

Call For Papers - 17th International Conference on Wireless & Mobile Networks...
Call For Papers - 17th International Conference on Wireless & Mobile Networks...
hosseinihamid192023
 
Rapid Prototyping for XR: Lecture 3 - Video and Paper Prototyping
Rapid Prototyping for XR: Lecture 3 - Video and Paper Prototyping
Mark Billinghurst
 
retina_biometrics ruet rajshahi bangdesh.pptx
retina_biometrics ruet rajshahi bangdesh.pptx
MdRakibulIslam697135
 
DESIGN OF REINFORCED CONCRETE ELEMENTS S
DESIGN OF REINFORCED CONCRETE ELEMENTS S
prabhusp8
 
Validating a Citizen Observatories enabling Platform by completing a Citizen ...
Validating a Citizen Observatories enabling Platform by completing a Citizen ...
Diego López-de-Ipiña González-de-Artaza
 
Solar thermal – Flat plate and concentrating collectors .pptx
Solar thermal – Flat plate and concentrating collectors .pptx
jdaniabraham1
 
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
resming1
 
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
SAMEER VISHWAKARMA
 
Introduction to Python Programming Language
Introduction to Python Programming Language
merlinjohnsy
 
Rapid Prototyping for XR: Lecture 1 Introduction to Prototyping
Rapid Prototyping for XR: Lecture 1 Introduction to Prototyping
Mark Billinghurst
 
Rapid Prototyping for XR: Lecture 4 - High Level Prototyping.
Rapid Prototyping for XR: Lecture 4 - High Level Prototyping.
Mark Billinghurst
 
Proposal for folders structure division in projects.pdf
Proposal for folders structure division in projects.pdf
Mohamed Ahmed
 
Tesla-Stock-Analysis-and-Forecast.pptx (1).pptx
Tesla-Stock-Analysis-and-Forecast.pptx (1).pptx
moonsony54
 
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
rr22001247
 
Introduction to Natural Language Processing - Stages in NLP Pipeline, Challen...
Introduction to Natural Language Processing - Stages in NLP Pipeline, Challen...
resming1
 
Deep Learning for Image Processing on 16 June 2025 MITS.pptx
Deep Learning for Image Processing on 16 June 2025 MITS.pptx
resming1
 
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
Shabista Imam
 
Cadastral Maps
Cadastral Maps
Google
 
Industry 4.o the fourth revolutionWeek-2.pptx
Industry 4.o the fourth revolutionWeek-2.pptx
KNaveenKumarECE
 
60 Years and Beyond eBook 1234567891.pdf
60 Years and Beyond eBook 1234567891.pdf
waseemalazzeh
 
Call For Papers - 17th International Conference on Wireless & Mobile Networks...
Call For Papers - 17th International Conference on Wireless & Mobile Networks...
hosseinihamid192023
 
Rapid Prototyping for XR: Lecture 3 - Video and Paper Prototyping
Rapid Prototyping for XR: Lecture 3 - Video and Paper Prototyping
Mark Billinghurst
 
retina_biometrics ruet rajshahi bangdesh.pptx
retina_biometrics ruet rajshahi bangdesh.pptx
MdRakibulIslam697135
 
DESIGN OF REINFORCED CONCRETE ELEMENTS S
DESIGN OF REINFORCED CONCRETE ELEMENTS S
prabhusp8
 
Validating a Citizen Observatories enabling Platform by completing a Citizen ...
Validating a Citizen Observatories enabling Platform by completing a Citizen ...
Diego López-de-Ipiña González-de-Artaza
 
Solar thermal – Flat plate and concentrating collectors .pptx
Solar thermal – Flat plate and concentrating collectors .pptx
jdaniabraham1
 
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
resming1
 
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
MATERIAL SCIENCE LECTURE NOTES FOR DIPLOMA STUDENTS
SAMEER VISHWAKARMA
 
Introduction to Python Programming Language
Introduction to Python Programming Language
merlinjohnsy
 
Rapid Prototyping for XR: Lecture 1 Introduction to Prototyping
Rapid Prototyping for XR: Lecture 1 Introduction to Prototyping
Mark Billinghurst
 
Rapid Prototyping for XR: Lecture 4 - High Level Prototyping.
Rapid Prototyping for XR: Lecture 4 - High Level Prototyping.
Mark Billinghurst
 
Proposal for folders structure division in projects.pdf
Proposal for folders structure division in projects.pdf
Mohamed Ahmed
 
Tesla-Stock-Analysis-and-Forecast.pptx (1).pptx
Tesla-Stock-Analysis-and-Forecast.pptx (1).pptx
moonsony54
 
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
rr22001247
 
Introduction to Natural Language Processing - Stages in NLP Pipeline, Challen...
Introduction to Natural Language Processing - Stages in NLP Pipeline, Challen...
resming1
 
Deep Learning for Image Processing on 16 June 2025 MITS.pptx
Deep Learning for Image Processing on 16 June 2025 MITS.pptx
resming1
 
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
FUNDAMENTALS OF COMPUTER ORGANIZATION AND ARCHITECTURE
Shabista Imam
 
Cadastral Maps
Cadastral Maps
Google
 
Industry 4.o the fourth revolutionWeek-2.pptx
Industry 4.o the fourth revolutionWeek-2.pptx
KNaveenKumarECE
 
60 Years and Beyond eBook 1234567891.pdf
60 Years and Beyond eBook 1234567891.pdf
waseemalazzeh
 
Ad

Types of keys in dbms

  • 1. “TYPES OF KEYS IN DATABASE” PRESENTED BY: DARSHAN HINGU
  • 2. OBJECTIVES  WHAT IS KEY?  Super Key  Primary Key  Candidate Key  Alternate Key  Foreign Key
  • 3. WHAT IS KEY?  Keys are very important part of Relational database model.  To maintain data integrity (that is data should be correct and in well formed) we use concept of keys.  It is used for identifying unique rows from table.  They are used to establish and identify relationships between tables.
  • 4. SUPER KEY  A super key is any combination of columns within a table that uniquely identifies each record within that table.  As an example, a table used to store customer master details could contain columns such as:  Customer name  Customer ID  Social Security number (SSN)  Address  Date of birth
  • 5.  A certain set of columns may be extracted and guaranteed unique to each customer. Examples of super keys are as follows:  Name+SSN+DOB  ID+Name+SSN  All keys are Super key but not vice versa.
  • 6. PRIMARY KEY  A primary key is a column in a table that uniquely identifies the rows in that table.  The data values placed in the primary key column must be unique to each row; no duplicates can be used.  Nulls are not allowed in primary key columns.  For example, in the table below, CustomerNo, which displays the ID number assigned to different customers, is the primary key.
  • 7.  CREATE TABLE CUSTOMER ( CustomerNO int NOT NULL PRIMARY KEY, FirstName varchar(20), LastName varchar(20) ); CustomerNo FirstName LastName 1 Sally Thompson 2 Sally Henderson 3 Harry Henderson 4 Sandra Wellington
  • 8. CANDIDATE KEY  There can be more than one candidate keys for a table.  A candidate key of a relation is a minimal super key for that relation.  A candidate key can be a combination of more than one columns.  A Candidate Key is a set of one or more columns that can identify a record uniquely in a table. There can be multiple Candidate Keys in one table.  Candidate keys are selected from the set of super keys, the only thing we take care while selecting candidate key is: It should not have any redundant attributes.
  • 9.  A primary key is being selected from the group of candidate keys.  The value of Candidate Key is non-null for every tuple.
  • 10. ALTERNATE KEY  Alternate keys are candidate keys that are not selected as primary key.  Alternate key is also called “Secondary Key”.  If any table have more than one candidate key, then after choosing primary key from those candidate key, rest of candidate keys are known as an alternate key of that table.
  • 11. FOREIGN KEY  Foreign key are those keys which is used to define relationship between two tables.  Foreign key are columns that point to primary key columns in other database tables.  It can accept multiple null, duplicate values.  It is also known as referential integrity.
  • 12.  --Course Table CREATE TABLE course ( courseid NUMBER(10) NOT NULL PRIMARY KEY, --primary key CourseName varchar2(10) NOT NULL, ) ; --Student Table CREATE TABLE Student ( studentId NUMBER(10) NOT NULL PRIMARY KEY, --primary key firstName varchar2(10) NOT NULL, lastName varchar2(10) NOT NULL, courseid NUMBER(10) REFERENCES course(courseid) --foreign key ) ; Example : We can have a courseid column in the Student table which is pointing to courseid column in a course table where it a primary key.