SlideShare a Scribd company logo
DBMS Keys
Asst.Prof. Rupali Lohar
Dept. of Computer Science & Engineering
B. R. Harne College Of Engineering & Technology, Karav, Post Vangani (W Tal
Ambernath, Mumbai, Maharashtra 421503
Overview:
• What are Keys?
• Why we need a Key?
• Various Keys in Database Management System
• What is Super key?
• What is Primary Key?
• What is Alternate key?
• What is Candidate Key?
• What is Foreign key?
• What is Compound key?
• What is Composite key?
• What is Surrogate Key?
• Difference Between Primary key & Foreign key
Key-
• Key helps you to identify a row(tuple) in a relation(table).
• They allow you to find the relation between two tables.
• Key is also helpful for finding unique record or row from the table.
• Each record with in a table can be uniquely identified bye
combination of one more fields in a table
Why we need a Key
• Keys help you to identify any row of data in a table.
• Help you to enforce identity and integrity in the relationship.
• Allows you to establish a relationship between and identify the
relation between tables
• Keys help you uniquely identify a row in a table by a combination of
one or more columns in that table.
Types of Keys in Database Management System
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.
• A table cannot have more than one primary key.
• In the EMPLOYEE table, ID can be primary key since it is unique for
each employee. In the EMPLOYEE table, we can even select
License_Number and Passport_Number as primary key since they are
also unique.
Candidate key
• A candidate key is an attribute or set of an attribute which can
uniquely identify a tuple.
• The remaining attributes except for primary key are considered as a
candidate key. The candidate keys are as strong as the primary key.
• 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
For example: In the EMPLOYEE table, id is best suited for the primary key. Rest of the
attributes like SSN, Passport_Number, and License_Number, etc. are considered as a
candidate key.
Example: In the given table Stud ID, Roll No, and email are candidate
keys which help us to uniquely identify the student record in the table.
Super Key
• Super key is a set of an attribute which can uniquely identify a tuple.
• Super key is a superset of a candidate key.
• A Super key may have additional attributes that are not needed for
unique identification.
• For example: In the above EMPLOYEE table, for(EMPLOEE_ID,
EMPLOYEE_NAME) 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.
Foreign key
• Foreign keys are the column of the table which is used to point to the
primary key of another table.
• In a company, every employee works in a specific department, and
employee and department are two different entities. So we can't
store the information of the department in the employee table. That's
why we link these two tables through the primary key of one table.
• We add the primary key of the DEPARTMENT table, Department_Id as
a new attribute in the EMPLOYEE table.
Now in the EMPLOYEE table, Department_Id is the foreign key, and both
the tables are related.
ALTERNATE KEYS
• 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.
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.
SURROGATE KEYS
• 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.
Surrogate keys in sql are allowed when
• No property has the parameter of the primary key.
• In the table when the primary key is too big or complicated.
• Which one of the following is a set of one or more attributes taken
collectively to uniquely identify a record?
• A. Candidate key
• B. Sub key
• C. Super key
• D. Foreign key
• Answer: Option C
• Explanation:
• Super key
• Super key is the superset of all the keys in a relation.
• Which one of the following cannot be taken as a primary key ?A. Id
• B. Register number
• C. Dept_id
• D. Street
• Answer: Option D
• Explanation:
• Street
• Street is the only attribute which can occur more than once.

More Related Content

What's hot

The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database Model
Shishir Aryal
 
Types Of Keys in DBMS
Types Of Keys in DBMSTypes Of Keys in DBMS
Types Of Keys in DBMS
PadamNepal1
 
Nested queries in database
Nested queries in databaseNested queries in database
Nested queries in database
Satya P. Joshi
 
joins in database
 joins in database joins in database
joins in database
Sultan Arshad
 
Data independence
Data independenceData independence
Data independence
Aashima Wadhwa
 
Sql join
Sql  joinSql  join
Sql join
Vikas Gupta
 
DATABASE CONSTRAINTS
DATABASE CONSTRAINTSDATABASE CONSTRAINTS
DATABASE CONSTRAINTS
sunanditaAnand
 
Constraints In Sql
Constraints In SqlConstraints In Sql
Constraints In SqlAnurag
 
ER Model in DBMS
ER Model in DBMSER Model in DBMS
ER Model in DBMS
Kabindra Koirala
 
Database design & Normalization (1NF, 2NF, 3NF)
Database design & Normalization (1NF, 2NF, 3NF)Database design & Normalization (1NF, 2NF, 3NF)
Database design & Normalization (1NF, 2NF, 3NF)
Jargalsaikhan Alyeksandr
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
Sabana Maharjan
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
Dashani Rajapaksha
 
Types of keys in dbms
Types of keys in dbmsTypes of keys in dbms
Types of keys in dbms
darshhingu
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
Raveena Thakur
 
Database constraints
Database constraintsDatabase constraints
Database constraints
Khadija Parween
 
RELATIONSHIP IN DBMS.pptx
RELATIONSHIP IN DBMS.pptxRELATIONSHIP IN DBMS.pptx
RELATIONSHIP IN DBMS.pptx
KAnurag2
 

What's hot (20)

The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database Model
 
Types Of Keys in DBMS
Types Of Keys in DBMSTypes Of Keys in DBMS
Types Of Keys in DBMS
 
Nested queries in database
Nested queries in databaseNested queries in database
Nested queries in database
 
joins in database
 joins in database joins in database
joins in database
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
Data independence
Data independenceData independence
Data independence
 
Joins And Its Types
Joins And Its TypesJoins And Its Types
Joins And Its Types
 
DBMS Keys
DBMS KeysDBMS Keys
DBMS Keys
 
Sql join
Sql  joinSql  join
Sql join
 
DATABASE CONSTRAINTS
DATABASE CONSTRAINTSDATABASE CONSTRAINTS
DATABASE CONSTRAINTS
 
Constraints In Sql
Constraints In SqlConstraints In Sql
Constraints In Sql
 
ER Model in DBMS
ER Model in DBMSER Model in DBMS
ER Model in DBMS
 
Database design & Normalization (1NF, 2NF, 3NF)
Database design & Normalization (1NF, 2NF, 3NF)Database design & Normalization (1NF, 2NF, 3NF)
Database design & Normalization (1NF, 2NF, 3NF)
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
Types of keys in dbms
Types of keys in dbmsTypes of keys in dbms
Types of keys in dbms
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
 
Databases: Normalisation
Databases: NormalisationDatabases: Normalisation
Databases: Normalisation
 
Database constraints
Database constraintsDatabase constraints
Database constraints
 
RELATIONSHIP IN DBMS.pptx
RELATIONSHIP IN DBMS.pptxRELATIONSHIP IN DBMS.pptx
RELATIONSHIP IN DBMS.pptx
 

Similar to Dbms keys

Dbms keysppt
Dbms keyspptDbms keysppt
Dbms keysppt
ArunakumariAkula1
 
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
sonudhakad173
 
Keys.pptx
Keys.pptxKeys.pptx
Keys.pptx
revathi s
 
computer-210809080138.pdf
computer-210809080138.pdfcomputer-210809080138.pdf
computer-210809080138.pdf
rahulsharma571283
 
DBMS_Keys.pdf
DBMS_Keys.pdfDBMS_Keys.pdf
DBMS_Keys.pdf
DianneParaase
 
SQL_DBMS_KEYS.pptx
SQL_DBMS_KEYS.pptxSQL_DBMS_KEYS.pptx
SQL_DBMS_KEYS.pptx
rahulsharma571283
 
Key in DatabaseManagementSystem_engineering.pptx
Key in DatabaseManagementSystem_engineering.pptxKey in DatabaseManagementSystem_engineering.pptx
Key in DatabaseManagementSystem_engineering.pptx
snehavenkatt27
 
DBMS-Keys , Attributes and Constraints.pptx
DBMS-Keys , Attributes and Constraints.pptxDBMS-Keys , Attributes and Constraints.pptx
DBMS-Keys , Attributes and Constraints.pptx
sajinis5
 
Keys in DBMS.pptx
Keys in DBMS.pptxKeys in DBMS.pptx
Keys in DBMS.pptx
Revathy V R
 
key1.pdf
key1.pdfkey1.pdf
key1.pdf
ajajkhan16
 
Keys used in database
Keys used in databaseKeys used in database
Keys used in database
university of Gujrat, pakistan
 
Keys in Database
Keys in DatabaseKeys in Database
Keys in Database
A. S. M. Shafi
 
DBMS Keys.pptx
DBMS Keys.pptxDBMS Keys.pptx
DBMS Keys.pptx
AryanGour1
 
Intro to Data warehousing lecture 12
Intro to Data warehousing   lecture 12Intro to Data warehousing   lecture 12
Intro to Data warehousing lecture 12
AnwarrChaudary
 
Doc 20191022-wa0041
Doc 20191022-wa0041Doc 20191022-wa0041
Doc 20191022-wa0041
university of Gujrat, pakistan
 
Databases - Unit 2.pdf
Databases - Unit 2.pdfDatabases - Unit 2.pdf
Databases - Unit 2.pdf
CynthiaAdzornu
 
key (1).pptx
key (1).pptxkey (1).pptx
key (1).pptx
KAnurag2
 
B & c
B & cB & c
DBMS:Relational Modal
DBMS:Relational ModalDBMS:Relational Modal
DBMS:Relational Modal
VaishnaviVaishnavi17
 
Keys presentation
Keys presentationKeys presentation
Keys presentation
mubeenkiran
 

Similar to Dbms keys (20)

Dbms keysppt
Dbms keyspptDbms keysppt
Dbms keysppt
 
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
 
Keys.pptx
Keys.pptxKeys.pptx
Keys.pptx
 
computer-210809080138.pdf
computer-210809080138.pdfcomputer-210809080138.pdf
computer-210809080138.pdf
 
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
 
Key in DatabaseManagementSystem_engineering.pptx
Key in DatabaseManagementSystem_engineering.pptxKey in DatabaseManagementSystem_engineering.pptx
Key in DatabaseManagementSystem_engineering.pptx
 
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
 
key1.pdf
key1.pdfkey1.pdf
key1.pdf
 
Keys used in database
Keys used in databaseKeys used in database
Keys used in database
 
Keys in Database
Keys in DatabaseKeys in Database
Keys in Database
 
DBMS Keys.pptx
DBMS Keys.pptxDBMS Keys.pptx
DBMS Keys.pptx
 
Intro to Data warehousing lecture 12
Intro to Data warehousing   lecture 12Intro to Data warehousing   lecture 12
Intro to Data warehousing lecture 12
 
Doc 20191022-wa0041
Doc 20191022-wa0041Doc 20191022-wa0041
Doc 20191022-wa0041
 
Databases - Unit 2.pdf
Databases - Unit 2.pdfDatabases - Unit 2.pdf
Databases - Unit 2.pdf
 
key (1).pptx
key (1).pptxkey (1).pptx
key (1).pptx
 
B & c
B & cB & c
B & c
 
DBMS:Relational Modal
DBMS:Relational ModalDBMS:Relational Modal
DBMS:Relational Modal
 
Keys presentation
Keys presentationKeys presentation
Keys presentation
 

More from RUpaliLohar

Lecture 08 mapping-converted
Lecture 08 mapping-convertedLecture 08 mapping-converted
Lecture 08 mapping-converted
RUpaliLohar
 
Relational model
Relational modelRelational model
Relational model
RUpaliLohar
 
Relational algebra.pptx
Relational algebra.pptxRelational algebra.pptx
Relational algebra.pptx
RUpaliLohar
 
Mobile ip
Mobile ipMobile ip
Mobile ip
RUpaliLohar
 
Mac
MacMac
gprs
gprsgprs
Relational model
Relational modelRelational model
Relational model
RUpaliLohar
 
EER MODEL
EER MODELEER MODEL
EER MODEL
RUpaliLohar
 
Gsm security algorithms A3 , A5 , A8
Gsm security algorithms A3 , A5 , A8Gsm security algorithms A3 , A5 , A8
Gsm security algorithms A3 , A5 , A8
RUpaliLohar
 
Localization & calling
Localization  & callingLocalization  & calling
Localization & calling
RUpaliLohar
 
Gsm signaling protocol
Gsm signaling protocolGsm signaling protocol
Gsm signaling protocol
RUpaliLohar
 
Mapping cardinality (cardinality constraint) in ER MODEL
Mapping cardinality (cardinality constraint) in ER MODELMapping cardinality (cardinality constraint) in ER MODEL
Mapping cardinality (cardinality constraint) in ER MODEL
RUpaliLohar
 
GSM Radio interface
GSM Radio interfaceGSM Radio interface
GSM Radio interface
RUpaliLohar
 
Gsm services
Gsm servicesGsm services
Gsm services
RUpaliLohar
 
Electromagnetic wave
Electromagnetic waveElectromagnetic wave
Electromagnetic wave
RUpaliLohar
 
Gsm architecture
Gsm architectureGsm architecture
Gsm architecture
RUpaliLohar
 
Entity relationship model
Entity relationship modelEntity relationship model
Entity relationship model
RUpaliLohar
 
Spread spectrum
Spread spectrumSpread spectrum
Spread spectrum
RUpaliLohar
 
Data model
Data modelData model
Data model
RUpaliLohar
 
DBMS architecture &; system structure
DBMS architecture &; system  structureDBMS architecture &; system  structure
DBMS architecture &; system structure
RUpaliLohar
 

More from RUpaliLohar (20)

Lecture 08 mapping-converted
Lecture 08 mapping-convertedLecture 08 mapping-converted
Lecture 08 mapping-converted
 
Relational model
Relational modelRelational model
Relational model
 
Relational algebra.pptx
Relational algebra.pptxRelational algebra.pptx
Relational algebra.pptx
 
Mobile ip
Mobile ipMobile ip
Mobile ip
 
Mac
MacMac
Mac
 
gprs
gprsgprs
gprs
 
Relational model
Relational modelRelational model
Relational model
 
EER MODEL
EER MODELEER MODEL
EER MODEL
 
Gsm security algorithms A3 , A5 , A8
Gsm security algorithms A3 , A5 , A8Gsm security algorithms A3 , A5 , A8
Gsm security algorithms A3 , A5 , A8
 
Localization & calling
Localization  & callingLocalization  & calling
Localization & calling
 
Gsm signaling protocol
Gsm signaling protocolGsm signaling protocol
Gsm signaling protocol
 
Mapping cardinality (cardinality constraint) in ER MODEL
Mapping cardinality (cardinality constraint) in ER MODELMapping cardinality (cardinality constraint) in ER MODEL
Mapping cardinality (cardinality constraint) in ER MODEL
 
GSM Radio interface
GSM Radio interfaceGSM Radio interface
GSM Radio interface
 
Gsm services
Gsm servicesGsm services
Gsm services
 
Electromagnetic wave
Electromagnetic waveElectromagnetic wave
Electromagnetic wave
 
Gsm architecture
Gsm architectureGsm architecture
Gsm architecture
 
Entity relationship model
Entity relationship modelEntity relationship model
Entity relationship model
 
Spread spectrum
Spread spectrumSpread spectrum
Spread spectrum
 
Data model
Data modelData model
Data model
 
DBMS architecture &; system structure
DBMS architecture &; system  structureDBMS architecture &; system  structure
DBMS architecture &; system structure
 

Recently uploaded

Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
ssuser9bd3ba
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
DuvanRamosGarzon1
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 

Recently uploaded (20)

Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 

Dbms keys

  • 1. DBMS Keys Asst.Prof. Rupali Lohar Dept. of Computer Science & Engineering B. R. Harne College Of Engineering & Technology, Karav, Post Vangani (W Tal Ambernath, Mumbai, Maharashtra 421503
  • 2. Overview: • What are Keys? • Why we need a Key? • Various Keys in Database Management System • What is Super key? • What is Primary Key? • What is Alternate key? • What is Candidate Key? • What is Foreign key? • What is Compound key? • What is Composite key? • What is Surrogate Key? • Difference Between Primary key & Foreign key
  • 3. Key- • Key helps you to identify a row(tuple) in a relation(table). • They allow you to find the relation between two tables. • Key is also helpful for finding unique record or row from the table. • Each record with in a table can be uniquely identified bye combination of one more fields in a table
  • 4. Why we need a Key • Keys help you to identify any row of data in a table. • Help you to enforce identity and integrity in the relationship. • Allows you to establish a relationship between and identify the relation between tables • Keys help you uniquely identify a row in a table by a combination of one or more columns in that table.
  • 5. Types of Keys in Database Management System
  • 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. • A table cannot have more than one primary key.
  • 7.
  • 8. • In the EMPLOYEE table, ID can be primary key since it is unique for each employee. In the EMPLOYEE table, we can even select License_Number and Passport_Number as primary key since they are also unique.
  • 9. Candidate key • A candidate key is an attribute or set of an attribute which can uniquely identify a tuple. • The remaining attributes except for primary key are considered as a candidate key. The candidate keys are as strong as the primary key. • 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.
  • 10. 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
  • 11. For example: In the EMPLOYEE table, id is best suited for the primary key. Rest of the attributes like SSN, Passport_Number, and License_Number, etc. are considered as a candidate key.
  • 12. Example: In the given table Stud ID, Roll No, and email are candidate keys which help us to uniquely identify the student record in the table.
  • 13. Super Key • Super key is a set of an attribute which can uniquely identify a tuple. • Super key is a superset of a candidate key. • A Super key may have additional attributes that are not needed for unique identification.
  • 14. • For example: In the above EMPLOYEE table, for(EMPLOEE_ID, EMPLOYEE_NAME) 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.
  • 15.
  • 16.
  • 17.
  • 18. Foreign key • Foreign keys are the column of the table which is used to point to the primary key of another table. • In a company, every employee works in a specific department, and employee and department are two different entities. So we can't store the information of the department in the employee table. That's why we link these two tables through the primary key of one table. • We add the primary key of the DEPARTMENT table, Department_Id as a new attribute in the EMPLOYEE table.
  • 19. Now in the EMPLOYEE table, Department_Id is the foreign key, and both the tables are related.
  • 20.
  • 21.
  • 22. ALTERNATE KEYS • 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.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27. 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.
  • 28.
  • 29.
  • 30. SURROGATE KEYS • 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. Surrogate keys in sql are allowed when • No property has the parameter of the primary key. • In the table when the primary key is too big or complicated.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35. • Which one of the following is a set of one or more attributes taken collectively to uniquely identify a record? • A. Candidate key • B. Sub key • C. Super key • D. Foreign key
  • 36. • Answer: Option C • Explanation: • Super key • Super key is the superset of all the keys in a relation.
  • 37. • Which one of the following cannot be taken as a primary key ?A. Id • B. Register number • C. Dept_id • D. Street
  • 38. • Answer: Option D • Explanation: • Street • Street is the only attribute which can occur more than once.