SlideShare a Scribd company logo
1 of 18
KEYS
Prepared by Visakh V, Assistant
Professor,Dept. of CSE, LBSITW
KEYS
 Used to establish and identify relation between
tables
 Each record with in a table can be uniquely
identified bye combination of one more fields in a
table
 Help to enforce integrity and identify relationship
Prepared by Visakh V, Assistant
Professor,Dept. of CSE, LBSITW
Different types of keys
1. Super Key
2. Candidate Key
3. Primary Key
4. Foreign Key
5. Secondary / Alternate key
6. Simple Key
7. Compound Key
8. Composite Key
Prepared by Visakh V, Assistant
Professor,Dept. of CSE, LBSITW
Super Key
 A Super key is any combination of fields
within a table that uniquely identifies each
record within that table.
 Superset of candidate key
Prepared by Visakh V, Assistant
Professor,Dept. of CSE, LBSITW
Candidate Key
 A subset of a super key.
 A candidate key is a single field or the least
combination of fields that uniquely identifies
each record in the table.
 The least combination of fields distinguishes
a candidate key from a super key. (ie.Minimal
Set of Super Key)
Every table must have at least one candidate
key but at the same time can have several.
Prepared by Visakh V, Assistant
Professor,Dept. of CSE, LBSITW
Prepared by Visakh V, Assistant
Professor,Dept. of CSE, LBSITW
In order to be eligible for a candidate key it
must pass certain criteria
I. It must contain unique values
II. Must not contain null values
III.Contain minimum number of fields to
ensure uniqueness
IV. Must uniquely identify each record in a
table
Prepared by Visakh V, Assistant
Professor,Dept. of CSE, LBSITW
Note: Once your candidate keys have been identified
you can now select one to be your primary key
Primary Key
Prepared by Visakh V, Assistant
Professor,Dept. of CSE, LBSITW
A primary key is a candidate key that is most
appropriate to be the main reference key for the
table.
It is the primary key of reference for the table
It is used throughout the database to help
establish relationships with other tables.
Prepared by Visakh V, Assistant
Professor,Dept. of CSE, LBSITW
Prepared by Visakh V, Assistant
Professor,Dept. of CSE, LBSITW
 Primary key must contain
• Unique values
• Must never be null
• Uniquely identify each record in the
table.
• Note : Primary keys are mandatory for
every table each record must have a value
for its primary key.
• Note: When choosing a primary key from
the pool of candidate keys always choose a
single simple key over a composite key.
Prepared by Visakh V, Assistant
Professor,Dept. of CSE, LBSITW
Foreign Key
 Foreign key is a column(s) that references a
column(s) of a table and it can be same table also
 A foreign key is generally a Unique key from one
table that appears as a field in another where the
first table has a relationship to the second.
 In other words, if we had a table A with a
Unique key X that linked to a table B where X was a
field in B, then X would be a foreign key in B.
Prepared by Visakh V, Assistant
Professor,Dept. of CSE, LBSITW
This relationship ensures
• Records cannot be inserted into a detail table if
corresponding record in the master table do not exist.
• Record of a master table cannot be deleted if
corresponding records in the detail table actually exist
Prepared by Visakh V, Assistant
Professor,Dept. of CSE, LBSITW
Parent
(or)
Master Table
Child
(or) Detail
table
Prepared by Visakh V, Assistant
Professor,Dept. of CSE, LBSITW
Parent must be UNIQUE OR PRIMARY KEY
Child may have DUPLICATE/NULL unless it is
specified
 Constraint specified on child not on parent
Parent record can delete only if no child
record exist
Parent cannot modify if child record exist
Prepared by Visakh V, Assistant
Professor,Dept. of CSE, LBSITW
Secondary / Alternate Key
 A table may have one or more choices for
the primary key. Collectively these are
known as candidate keys.
 One is selected as the primary key. Those
not selected are known as secondary keys
or alternative keys.
Prepared by Visakh V, Assistant
Professor,Dept. of CSE, LBSITW
Simple Key
 A simple key consists of a single field to uniquely
identify a record.
In addition the field in itself cannot be broken
down into other fields
Prepared by Visakh V, Assistant
Professor,Dept. of CSE, LBSITW
Compound Key
A compound key consists of more than one
field to uniquely identify a record.
 Each attribute that makes up the compound
key is a simple key in its own right.
Prepared by Visakh V, Assistant
Professor,Dept. of CSE, LBSITW
Composite Key
 A composite key consists of more than one
field to uniquely identify a record.
 This differs from a compound key in that one
or more of the attributes, which make up the
key, are not simple keys in their own right

More Related Content

What's hot

What's hot (20)

Introduction of sql server indexing
Introduction of sql server indexingIntroduction of sql server indexing
Introduction of sql server indexing
 
Dbms keys
Dbms keysDbms keys
Dbms keys
 
Sql join
Sql  joinSql  join
Sql join
 
Keys in dbms
Keys in dbmsKeys in dbms
Keys in dbms
 
Database Keys & Relationship
Database Keys & RelationshipDatabase Keys & Relationship
Database Keys & Relationship
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
DBMS Keys
DBMS KeysDBMS Keys
DBMS Keys
 
Sql joins
Sql joinsSql joins
Sql joins
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
 
DML Commands
DML CommandsDML Commands
DML Commands
 
SQL Joins.pptx
SQL Joins.pptxSQL Joins.pptx
SQL Joins.pptx
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
 
Types of keys in database | SQL
Types of keys in database | SQLTypes of keys in database | SQL
Types of keys in database | SQL
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
 
Relational model
Relational modelRelational model
Relational model
 
SQL subquery
SQL subquerySQL subquery
SQL subquery
 
Sql Constraints
Sql ConstraintsSql Constraints
Sql Constraints
 
MYSQL Aggregate Functions
MYSQL Aggregate FunctionsMYSQL Aggregate Functions
MYSQL Aggregate Functions
 
Trigger
TriggerTrigger
Trigger
 
Index in sql server
Index in sql serverIndex in sql server
Index in sql server
 

Viewers also liked (13)

ER Model in DBMS
ER Model in DBMSER Model in DBMS
ER Model in DBMS
 
Relational keys
Relational keysRelational keys
Relational keys
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS
 
6. Integrity and Security in DBMS
6. Integrity and Security in DBMS6. Integrity and Security in DBMS
6. Integrity and Security in DBMS
 
Sql Authorization
Sql AuthorizationSql Authorization
Sql Authorization
 
Set operators
Set  operatorsSet  operators
Set operators
 
View of data DBMS
View of data DBMSView of data DBMS
View of data DBMS
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
 
RAID
RAIDRAID
RAID
 
DBMS - Normalization
DBMS - NormalizationDBMS - Normalization
DBMS - Normalization
 
Database Keys
Database KeysDatabase Keys
Database Keys
 

Similar to Slide 5 keys (8)

Dbms keysppt
Dbms keyspptDbms keysppt
Dbms keysppt
 
SQL_DBMS_KEYS.pptx
SQL_DBMS_KEYS.pptxSQL_DBMS_KEYS.pptx
SQL_DBMS_KEYS.pptx
 
Keys in Database
Keys in DatabaseKeys in Database
Keys in Database
 
B & c
B & cB & c
B & c
 
A Presentation of Types of Keys in RDBMS.pptx
A Presentation of Types of Keys in RDBMS.pptxA Presentation of Types of Keys in RDBMS.pptx
A Presentation of Types of Keys in RDBMS.pptx
 
computer-210809080138.pdf
computer-210809080138.pdfcomputer-210809080138.pdf
computer-210809080138.pdf
 
2.2 keys
2.2 keys2.2 keys
2.2 keys
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database Model
 

More from Visakh V

More from Visakh V (15)

Functional dependency and normalization
Functional dependency and normalizationFunctional dependency and normalization
Functional dependency and normalization
 
Data base recovery
Data base recoveryData base recovery
Data base recovery
 
Relational algebra complete
Relational algebra completeRelational algebra complete
Relational algebra complete
 
Slide 4 dbms users
Slide 4 dbms usersSlide 4 dbms users
Slide 4 dbms users
 
Transaction Management
Transaction Management Transaction Management
Transaction Management
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Slide 4 dbms users
Slide 4 dbms usersSlide 4 dbms users
Slide 4 dbms users
 
Slide 6 er strong & weak entity
Slide 6 er  strong & weak entitySlide 6 er  strong & weak entity
Slide 6 er strong & weak entity
 
Slide 3 data abstraction & 3 schema
Slide 3 data abstraction & 3 schemaSlide 3 data abstraction & 3 schema
Slide 3 data abstraction & 3 schema
 
Slide 2 data models
Slide 2 data modelsSlide 2 data models
Slide 2 data models
 
Slide 1 introduction to dbms
Slide 1 introduction to dbmsSlide 1 introduction to dbms
Slide 1 introduction to dbms
 
Data
DataData
Data
 
Functional dependancy
Functional dependancyFunctional dependancy
Functional dependancy
 
Relational algebr
Relational algebrRelational algebr
Relational algebr
 
data constraints,group by
data constraints,group by data constraints,group by
data constraints,group by
 

Recently uploaded

Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
pritamlangde
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 

Recently uploaded (20)

UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptx
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Digital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptxDigital Communication Essentials: DPCM, DM, and ADM .pptx
Digital Communication Essentials: DPCM, DM, and ADM .pptx
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To Curves
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
💚Trustworthy Call Girls Pune Call Girls Service Just Call 🍑👄6378878445 🍑👄 Top...
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Ground Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth ReinforcementGround Improvement Technique: Earth Reinforcement
Ground Improvement Technique: Earth Reinforcement
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
Electromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxElectromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptx
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 

Slide 5 keys

  • 1. KEYS Prepared by Visakh V, Assistant Professor,Dept. of CSE, LBSITW
  • 2. KEYS  Used to establish and identify relation between tables  Each record with in a table can be uniquely identified bye combination of one more fields in a table  Help to enforce integrity and identify relationship Prepared by Visakh V, Assistant Professor,Dept. of CSE, LBSITW
  • 3. Different types of keys 1. Super Key 2. Candidate Key 3. Primary Key 4. Foreign Key 5. Secondary / Alternate key 6. Simple Key 7. Compound Key 8. Composite Key Prepared by Visakh V, Assistant Professor,Dept. of CSE, LBSITW
  • 4. Super Key  A Super key is any combination of fields within a table that uniquely identifies each record within that table.  Superset of candidate key Prepared by Visakh V, Assistant Professor,Dept. of CSE, LBSITW
  • 5. Candidate Key  A subset of a super key.  A candidate key is a single field or the least combination of fields that uniquely identifies each record in the table.  The least combination of fields distinguishes a candidate key from a super key. (ie.Minimal Set of Super Key) Every table must have at least one candidate key but at the same time can have several. Prepared by Visakh V, Assistant Professor,Dept. of CSE, LBSITW
  • 6. Prepared by Visakh V, Assistant Professor,Dept. of CSE, LBSITW
  • 7. In order to be eligible for a candidate key it must pass certain criteria I. It must contain unique values II. Must not contain null values III.Contain minimum number of fields to ensure uniqueness IV. Must uniquely identify each record in a table Prepared by Visakh V, Assistant Professor,Dept. of CSE, LBSITW Note: Once your candidate keys have been identified you can now select one to be your primary key
  • 8. Primary Key Prepared by Visakh V, Assistant Professor,Dept. of CSE, LBSITW A primary key is a candidate key that is most appropriate to be the main reference key for the table. It is the primary key of reference for the table It is used throughout the database to help establish relationships with other tables.
  • 9. Prepared by Visakh V, Assistant Professor,Dept. of CSE, LBSITW
  • 10. Prepared by Visakh V, Assistant Professor,Dept. of CSE, LBSITW  Primary key must contain • Unique values • Must never be null • Uniquely identify each record in the table. • Note : Primary keys are mandatory for every table each record must have a value for its primary key. • Note: When choosing a primary key from the pool of candidate keys always choose a single simple key over a composite key.
  • 11. Prepared by Visakh V, Assistant Professor,Dept. of CSE, LBSITW Foreign Key  Foreign key is a column(s) that references a column(s) of a table and it can be same table also  A foreign key is generally a Unique key from one table that appears as a field in another where the first table has a relationship to the second.  In other words, if we had a table A with a Unique key X that linked to a table B where X was a field in B, then X would be a foreign key in B.
  • 12. Prepared by Visakh V, Assistant Professor,Dept. of CSE, LBSITW This relationship ensures • Records cannot be inserted into a detail table if corresponding record in the master table do not exist. • Record of a master table cannot be deleted if corresponding records in the detail table actually exist
  • 13. Prepared by Visakh V, Assistant Professor,Dept. of CSE, LBSITW Parent (or) Master Table Child (or) Detail table
  • 14. Prepared by Visakh V, Assistant Professor,Dept. of CSE, LBSITW Parent must be UNIQUE OR PRIMARY KEY Child may have DUPLICATE/NULL unless it is specified  Constraint specified on child not on parent Parent record can delete only if no child record exist Parent cannot modify if child record exist
  • 15. Prepared by Visakh V, Assistant Professor,Dept. of CSE, LBSITW Secondary / Alternate Key  A table may have one or more choices for the primary key. Collectively these are known as candidate keys.  One is selected as the primary key. Those not selected are known as secondary keys or alternative keys.
  • 16. Prepared by Visakh V, Assistant Professor,Dept. of CSE, LBSITW Simple Key  A simple key consists of a single field to uniquely identify a record. In addition the field in itself cannot be broken down into other fields
  • 17. Prepared by Visakh V, Assistant Professor,Dept. of CSE, LBSITW Compound Key A compound key consists of more than one field to uniquely identify a record.  Each attribute that makes up the compound key is a simple key in its own right.
  • 18. Prepared by Visakh V, Assistant Professor,Dept. of CSE, LBSITW Composite Key  A composite key consists of more than one field to uniquely identify a record.  This differs from a compound key in that one or more of the attributes, which make up the key, are not simple keys in their own right