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.
Dbms keys
• 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.
Dbms keys
Dbms keys
Dbms keys
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.
Dbms keys
Dbms keys
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.
Dbms keys
Dbms keys
Dbms keys
Dbms keys
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.
Dbms keys
Dbms keys
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.
Dbms keys
Dbms keys
Dbms keys
Dbms keys
• 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

PPTX
Types Of Keys in DBMS
PPT
SQL Queries
PPTX
DATABASE CONSTRAINTS
PPTX
The Relational Database Model
PPT
Half adder & full adder
PPTX
SQL(DDL & DML)
PPTX
Relational model
PDF
Basics of image processing using MATLAB
Types Of Keys in DBMS
SQL Queries
DATABASE CONSTRAINTS
The Relational Database Model
Half adder & full adder
SQL(DDL & DML)
Relational model
Basics of image processing using MATLAB

What's hot (20)

PPTX
Degree of relationship set
PPTX
PPTX
database language ppt.pptx
PDF
Relational algebra in dbms
PPTX
Integrity Constraints
PPTX
Acid properties
PPTX
Joins And Its Types
PPT
Database Keys
PPTX
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
PPTX
Relational algebra ppt
PPTX
Data Manipulation Language
PPTX
DBMS Keys
PPT
ER-Model-ER Diagram
PPT
Constraints In Sql
PPTX
Key and its different types
PPTX
B and B+ tree
PPT
Sql operators & functions 3
PDF
Normalization in DBMS
Degree of relationship set
database language ppt.pptx
Relational algebra in dbms
Integrity Constraints
Acid properties
Joins And Its Types
Database Keys
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
Relational algebra ppt
Data Manipulation Language
DBMS Keys
ER-Model-ER Diagram
Constraints In Sql
Key and its different types
B and B+ tree
Sql operators & functions 3
Normalization in DBMS
Ad

Similar to Dbms keys (20)

PPTX
Dbms keysppt
PPTX
DBMS key topic Presentation slide 1.pptx
PPTX
Types of keys dbms
PPTX
Keys.pptx
PPTX
Keys_in_DBMS_VALID_INFORMATION_IS_AVAILA
PDF
computer-210809080138.pdf
PDF
DBMS_Keys.pdf
PPTX
Types of keys in database | SQL
PPTX
Types of keys in dbms
PPTX
SQL_DBMS_KEYS.pptx
PPTX
Key in DatabaseManagementSystem_engineering.pptx
PPTX
DBMS-Keys , Attributes and Constraints.pptx
PPTX
fundamentals-of-database.pptx hehehehehe
PDF
DBMS VHGFGJKFHVGFJKHHFVHGFHBBVVHGVVHGVBVHG
PPTX
Keys in DBMS.pptx
PPTX
Relational Data Model| Database system.pptx
PPTX
KEYS IN DBMS.pptx soap ui kkeys and eclipse id
PPTX
Steps to create an ER Diagram, ER model Keys.pptx
PDF
key1.pdf
DOCX
Keys used in database
Dbms keysppt
DBMS key topic Presentation slide 1.pptx
Types of keys dbms
Keys.pptx
Keys_in_DBMS_VALID_INFORMATION_IS_AVAILA
computer-210809080138.pdf
DBMS_Keys.pdf
Types of keys in database | SQL
Types of keys in dbms
SQL_DBMS_KEYS.pptx
Key in DatabaseManagementSystem_engineering.pptx
DBMS-Keys , Attributes and Constraints.pptx
fundamentals-of-database.pptx hehehehehe
DBMS VHGFGJKFHVGFJKHHFVHGFHBBVVHGVVHGVBVHG
Keys in DBMS.pptx
Relational Data Model| Database system.pptx
KEYS IN DBMS.pptx soap ui kkeys and eclipse id
Steps to create an ER Diagram, ER model Keys.pptx
key1.pdf
Keys used in database
Ad

More from RUpaliLohar (20)

PPTX
Lecture 08 mapping-converted
PPTX
Relational model
PPT
Relational algebra.pptx
PPTX
Mobile ip
PPTX
PPTX
PPTX
Relational model
PPTX
EER MODEL
PPTX
Gsm security algorithms A3 , A5 , A8
PPTX
Localization & calling
PPTX
Gsm signaling protocol
PPTX
Mapping cardinality (cardinality constraint) in ER MODEL
PPTX
GSM Radio interface
PPTX
Gsm services
PPTX
Electromagnetic wave
PPTX
Gsm architecture
PPTX
Entity relationship model
PPTX
Spread spectrum
PPTX
Data model
PPTX
DBMS architecture &; system structure
Lecture 08 mapping-converted
Relational model
Relational algebra.pptx
Mobile ip
Relational model
EER MODEL
Gsm security algorithms A3 , A5 , A8
Localization & calling
Gsm signaling protocol
Mapping cardinality (cardinality constraint) in ER MODEL
GSM Radio interface
Gsm services
Electromagnetic wave
Gsm architecture
Entity relationship model
Spread spectrum
Data model
DBMS architecture &; system structure

Recently uploaded (20)

PDF
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Categorization of Factors Affecting Classification Algorithms Selection
PPT
Total quality management ppt for engineering students
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
PPTX
communication and presentation skills 01
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
Soil Improvement Techniques Note - Rabbi
PPT
A5_DistSysCh1.ppt_INTRODUCTION TO DISTRIBUTED SYSTEMS
PDF
Visual Aids for Exploratory Data Analysis.pdf
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Safety Seminar civil to be ensured for safe working.
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
PDF
86236642-Electric-Loco-Shed.pdf jfkduklg
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Categorization of Factors Affecting Classification Algorithms Selection
Total quality management ppt for engineering students
Exploratory_Data_Analysis_Fundamentals.pdf
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
communication and presentation skills 01
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Soil Improvement Techniques Note - Rabbi
A5_DistSysCh1.ppt_INTRODUCTION TO DISTRIBUTED SYSTEMS
Visual Aids for Exploratory Data Analysis.pdf
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Safety Seminar civil to be ensured for safe working.
III.4.1.2_The_Space_Environment.p pdffdf
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
86236642-Electric-Loco-Shed.pdf jfkduklg

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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.