SlideShare a Scribd company logo
1 of 38
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

FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLEVraj Patel
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraintsmadhav bansal
 
Key and its different types
Key and its different typesKey and its different types
Key and its different typesUmair Shakir
 
joins in database
 joins in database joins in database
joins in databaseSultan Arshad
 
Lecture 04 normalization
Lecture 04 normalization Lecture 04 normalization
Lecture 04 normalization emailharmeet
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked ListNinad Mankar
 
Using the set operators
Using the set operatorsUsing the set operators
Using the set operatorsSyed Zaid Irshad
 
The Relational Model
The Relational ModelThe Relational Model
The Relational ModelBhandari Nawaraj
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL CommandsShrija Madhu
 
Integrity constraints in dbms
Integrity constraints in dbmsIntegrity constraints in dbms
Integrity constraints in dbmsVignesh Saravanan
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMSkoolkampus
 
Constraints In Sql
Constraints In SqlConstraints In Sql
Constraints In SqlAnurag
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database ModelShishir Aryal
 

What's hot (20)

ER-Model-ER Diagram
ER-Model-ER DiagramER-Model-ER Diagram
ER-Model-ER Diagram
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
 
Sql Constraints
Sql ConstraintsSql Constraints
Sql Constraints
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Key and its different types
Key and its different typesKey and its different types
Key and its different types
 
joins in database
 joins in database joins in database
joins in database
 
Lecture 04 normalization
Lecture 04 normalization Lecture 04 normalization
Lecture 04 normalization
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
Using the set operators
Using the set operatorsUsing the set operators
Using the set operators
 
The Relational Model
The Relational ModelThe Relational Model
The Relational Model
 
Joins And Its Types
Joins And Its TypesJoins And Its Types
Joins And Its Types
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
Integrity constraints in dbms
Integrity constraints in dbmsIntegrity constraints in dbms
Integrity constraints in dbms
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS
 
Constraints In Sql
Constraints In SqlConstraints In Sql
Constraints In Sql
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database Model
 
Bcnf
BcnfBcnf
Bcnf
 
Relational model
Relational modelRelational model
Relational model
 

Similar to Dbms keys

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.pptxsonudhakad173
 
Types of keys dbms
Types of keys dbmsTypes of keys dbms
Types of keys dbmsSurkhab Shelly
 
Keys.pptx
Keys.pptxKeys.pptx
Keys.pptxrevathi s
 
computer-210809080138.pdf
computer-210809080138.pdfcomputer-210809080138.pdf
computer-210809080138.pdfrahulsharma571283
 
Types of keys in database | SQL
Types of keys in database | SQLTypes of keys in database | SQL
Types of keys in database | SQLSumit Pandey
 
Key in DatabaseManagementSystem_engineering.pptx
Key in DatabaseManagementSystem_engineering.pptxKey in DatabaseManagementSystem_engineering.pptx
Key in DatabaseManagementSystem_engineering.pptxsnehavenkatt27
 
DBMS-Keys , Attributes and Constraints.pptx
DBMS-Keys , Attributes and Constraints.pptxDBMS-Keys , Attributes and Constraints.pptx
DBMS-Keys , Attributes and Constraints.pptxsajinis5
 
Keys in DBMS.pptx
Keys in DBMS.pptxKeys in DBMS.pptx
Keys in DBMS.pptxRevathy V R
 
key1.pdf
key1.pdfkey1.pdf
key1.pdfajajkhan16
 
Keys in Database
Keys in DatabaseKeys in Database
Keys in DatabaseA. S. M. Shafi
 
DBMS Keys.pptx
DBMS Keys.pptxDBMS Keys.pptx
DBMS Keys.pptxAryanGour1
 
Intro to Data warehousing lecture 12
Intro to Data warehousing   lecture 12Intro to Data warehousing   lecture 12
Intro to Data warehousing lecture 12AnwarrChaudary
 
Databases - Unit 2.pdf
Databases - Unit 2.pdfDatabases - Unit 2.pdf
Databases - Unit 2.pdfCynthiaAdzornu
 
key (1).pptx
key (1).pptxkey (1).pptx
key (1).pptxKAnurag2
 

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
 
Types of keys dbms
Types of keys dbmsTypes of keys dbms
Types of keys dbms
 
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
 
Types of keys in database | SQL
Types of keys in database | SQLTypes of keys in database | SQL
Types of keys in database | SQL
 
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
 

More from RUpaliLohar

Lecture 08 mapping-converted
Lecture 08 mapping-convertedLecture 08 mapping-converted
Lecture 08 mapping-convertedRUpaliLohar
 
Relational model
Relational modelRelational model
Relational modelRUpaliLohar
 
Relational algebra.pptx
Relational algebra.pptxRelational algebra.pptx
Relational algebra.pptxRUpaliLohar
 
Relational model
Relational modelRelational model
Relational modelRUpaliLohar
 
Gsm security algorithms A3 , A5 , A8
Gsm security algorithms A3 , A5 , A8Gsm security algorithms A3 , A5 , A8
Gsm security algorithms A3 , A5 , A8RUpaliLohar
 
Localization & calling
Localization  & callingLocalization  & calling
Localization & callingRUpaliLohar
 
Gsm signaling protocol
Gsm signaling protocolGsm signaling protocol
Gsm signaling protocolRUpaliLohar
 
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 MODELRUpaliLohar
 
GSM Radio interface
GSM Radio interfaceGSM Radio interface
GSM Radio interfaceRUpaliLohar
 
Gsm services
Gsm servicesGsm services
Gsm servicesRUpaliLohar
 
Electromagnetic wave
Electromagnetic waveElectromagnetic wave
Electromagnetic waveRUpaliLohar
 
Gsm architecture
Gsm architectureGsm architecture
Gsm architectureRUpaliLohar
 
Entity relationship model
Entity relationship modelEntity relationship model
Entity relationship modelRUpaliLohar
 
Spread spectrum
Spread spectrumSpread spectrum
Spread spectrumRUpaliLohar
 
Data model
Data modelData model
Data modelRUpaliLohar
 
DBMS architecture &; system structure
DBMS architecture &; system  structureDBMS architecture &; system  structure
DBMS architecture &; system structureRUpaliLohar
 

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

MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 

Recently uploaded (20)

MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 

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.