SlideShare a Scribd company logo
1 of 18
Download to read offline
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

More from BhanuCharan9

SOCIAL DISTANCE DETECTION.pptx
SOCIAL DISTANCE DETECTION.pptxSOCIAL DISTANCE DETECTION.pptx
SOCIAL DISTANCE DETECTION.pptxBhanuCharan9
 
diskmanagement-170307012154.pdf
diskmanagement-170307012154.pdfdiskmanagement-170307012154.pdf
diskmanagement-170307012154.pdfBhanuCharan9
 
productionanalysis-090913125852-phpapp01.pdf
productionanalysis-090913125852-phpapp01.pdfproductionanalysis-090913125852-phpapp01.pdf
productionanalysis-090913125852-phpapp01.pdfBhanuCharan9
 
marketstructurereview-121123101318-phpapp02.pdf
marketstructurereview-121123101318-phpapp02.pdfmarketstructurereview-121123101318-phpapp02.pdf
marketstructurereview-121123101318-phpapp02.pdfBhanuCharan9
 
unit1rulesofinference-170113152312.pdf
unit1rulesofinference-170113152312.pdfunit1rulesofinference-170113152312.pdf
unit1rulesofinference-170113152312.pdfBhanuCharan9
 
mathematicalinductionanddivisibilityrules-160711105713.pdf
mathematicalinductionanddivisibilityrules-160711105713.pdfmathematicalinductionanddivisibilityrules-160711105713.pdf
mathematicalinductionanddivisibilityrules-160711105713.pdfBhanuCharan9
 
Blockchain Banking 0th Review.pptx
Blockchain Banking 0th Review.pptxBlockchain Banking 0th Review.pptx
Blockchain Banking 0th Review.pptxBhanuCharan9
 
timesproet-180212053847.pdf
timesproet-180212053847.pdftimesproet-180212053847.pdf
timesproet-180212053847.pdfBhanuCharan9
 
neerajppt-130323071407-phpapp02.pdf
neerajppt-130323071407-phpapp02.pdfneerajppt-130323071407-phpapp02.pdf
neerajppt-130323071407-phpapp02.pdfBhanuCharan9
 
criticalsectionproblem-160905215747.pdf
criticalsectionproblem-160905215747.pdfcriticalsectionproblem-160905215747.pdf
criticalsectionproblem-160905215747.pdfBhanuCharan9
 
analysisofsupply-160417044322.pdf
analysisofsupply-160417044322.pdfanalysisofsupply-160417044322.pdf
analysisofsupply-160417044322.pdfBhanuCharan9
 
relationsandfunctionslessonproper-160929053921.pdf
relationsandfunctionslessonproper-160929053921.pdfrelationsandfunctionslessonproper-160929053921.pdf
relationsandfunctionslessonproper-160929053921.pdfBhanuCharan9
 

More from BhanuCharan9 (16)

SOCIAL DISTANCE DETECTION.pptx
SOCIAL DISTANCE DETECTION.pptxSOCIAL DISTANCE DETECTION.pptx
SOCIAL DISTANCE DETECTION.pptx
 
BLOCKHUNTER.pptx
BLOCKHUNTER.pptxBLOCKHUNTER.pptx
BLOCKHUNTER.pptx
 
diskmanagement-170307012154.pdf
diskmanagement-170307012154.pdfdiskmanagement-170307012154.pdf
diskmanagement-170307012154.pdf
 
productionanalysis-090913125852-phpapp01.pdf
productionanalysis-090913125852-phpapp01.pdfproductionanalysis-090913125852-phpapp01.pdf
productionanalysis-090913125852-phpapp01.pdf
 
marketstructurereview-121123101318-phpapp02.pdf
marketstructurereview-121123101318-phpapp02.pdfmarketstructurereview-121123101318-phpapp02.pdf
marketstructurereview-121123101318-phpapp02.pdf
 
unit1rulesofinference-170113152312.pdf
unit1rulesofinference-170113152312.pdfunit1rulesofinference-170113152312.pdf
unit1rulesofinference-170113152312.pdf
 
mathematicalinductionanddivisibilityrules-160711105713.pdf
mathematicalinductionanddivisibilityrules-160711105713.pdfmathematicalinductionanddivisibilityrules-160711105713.pdf
mathematicalinductionanddivisibilityrules-160711105713.pdf
 
0th-review-1.pptx
0th-review-1.pptx0th-review-1.pptx
0th-review-1.pptx
 
Blockchain Banking 0th Review.pptx
Blockchain Banking 0th Review.pptxBlockchain Banking 0th Review.pptx
Blockchain Banking 0th Review.pptx
 
timesproet-180212053847.pdf
timesproet-180212053847.pdftimesproet-180212053847.pdf
timesproet-180212053847.pdf
 
neerajppt-130323071407-phpapp02.pdf
neerajppt-130323071407-phpapp02.pdfneerajppt-130323071407-phpapp02.pdf
neerajppt-130323071407-phpapp02.pdf
 
criticalsectionproblem-160905215747.pdf
criticalsectionproblem-160905215747.pdfcriticalsectionproblem-160905215747.pdf
criticalsectionproblem-160905215747.pdf
 
analysisofsupply-160417044322.pdf
analysisofsupply-160417044322.pdfanalysisofsupply-160417044322.pdf
analysisofsupply-160417044322.pdf
 
relationsandfunctionslessonproper-160929053921.pdf
relationsandfunctionslessonproper-160929053921.pdfrelationsandfunctionslessonproper-160929053921.pdf
relationsandfunctionslessonproper-160929053921.pdf
 
coloring.pptx
coloring.pptxcoloring.pptx
coloring.pptx
 
coloring.ppt
coloring.pptcoloring.ppt
coloring.ppt
 

Recently uploaded

DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024APNIC
 
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$kojalkojal131
 
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Roomdivyansh0kumar0
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on DeliveryCall Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Deliverybabeytanya
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girladitipandeya
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Sheetaleventcompany
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012rehmti665
 
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Roomdivyansh0kumar0
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024APNIC
 
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With RoomVIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Roomgirls4nights
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Delhi Call girls
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 

Recently uploaded (20)

DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
 
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on DeliveryCall Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
Call Girls South Delhi Delhi reach out to us at ☎ 9711199012
 
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
 
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024
 
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With RoomVIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Uttam Nagar Delhi 💯Call Us 🔝8264348440🔝
 

slide5keys-140722233859-phpapp02.pdf

  • 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