SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Keys
A key is a field or set of fields whose values uniquely identify a record.
In this example, we could use SCN as a key because it uniquely identifies a
pupil record. No other pupil can have the same SCN (Scottish Candidate
Number).
No other fields can uniquely identify each pupil record
Candidate Key
Any field or set of fields which can be considered as a key is known as a
candidate key
In this example, both Employee Number and Email are candidate keys,
because both can uniquely identify the employee record in the table
Primary Key
The primary key is the candidate key which is chosen to be used
In the example above, it's possible that the company may change the structure
of staff email addresses. Given this, it would be better to use Employee
Number as a primary key as this is less likely to change.
A primary key consisting of only one field is known as an atomic key
Compound Key
It is possible in some tables that no one column can act as a primary key, and
that a combination of columns are required to create the key. This is known as
a compound key.
Order ID cannot be a primary key as it does not uniquely identify a record
Product ID cannot be a primary key as it does not uniquely identify a record
Compound Key
It is possible in some tables that no one column can act as a primary key, and
that a combination of columns are required to create the key. This is known as
a compound key.
A compound key of Order ID and Product ID could be used because this is
unique for each record.
Surrogate Key
A surrogate key is a special key which has no meaning or purpose other than to
uniquely identify each record. Surrogate keys are often a combination of letters
and numbers. A new column is created to be the primary key.
Surrogate Key
A surrogate key is a special key which has no meaning or purpose other than to
uniquely identify each record. Surrogate keys are often a combination of letters
and numbers. A new column is created to be the primary key.
In this example, KTV have been interviewing passers-by for the evening news
bulletin. The production team take a note of the interviewee's name and the
duration of the interview.
As these people are not related to KTV in anyway, a surrogate key must be
created in order to uniquely identify them.
Surrogate Key
A surrogate key is a special key which has no meaning or purpose other than to
uniquely identify each record. Surrogate keys are often a combination of letters
and numbers. A new column is created to be the primary key.
In this example, KTV have been interviewing passers-by for the evening news
bulletin. The production team take a note of the interviewee's name and the
duration of the interview.
As these people are not related to KTV in anyway, a surrogate key must be
created in order to uniquely identify them.
Foreign Key
A foreign key is a column which is added to one table to create a relationship
with another table.
In this example we have two tables, teachers and departments in a school.
But there is no way to see which teacher works in which department.
Foreign Key
A foreign key is a column which is added to one table to create a relationship
with another table.
By adding the foreign key Department Code to the Teacher table, we can
create a relationship between the two tables.
Key Notation
We represent primary keys by underlining them.
We represent foreign keys with an asterisk.
Key Notation
We represent primary keys by underlining them.
We represent foreign keys with an asterisk.
young scot card (card_num, name, expiry_date, photo)
pupil (candidate_num, forename, surname, dob, card_num*)
Key Notation
We represent primary keys by underlining them.
We represent foreign keys with an asterisk.
pupil (candidate_num, forename, surname, dob, postcode)
exam (exam_id, subject, level, duration)
result (candidate_num*, exam_id*, grade)
Key Notation
We represent primary keys by underlining them.
We represent foreign keys with an asterisk.
movie (movie_id, name, certificate, rating)
cinema (cinema_id, city, telephone)
screening (cinema*, movie*, date, time)

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Primary Key & Foreign Key part10
Primary Key & Foreign Key part10Primary Key & Foreign Key part10
Primary Key & Foreign Key part10
 
Dbms Notes Lecture 9 : Specialization, Generalization and Aggregation
Dbms Notes Lecture 9 : Specialization, Generalization and AggregationDbms Notes Lecture 9 : Specialization, Generalization and Aggregation
Dbms Notes Lecture 9 : Specialization, Generalization and Aggregation
 
Er model ppt
Er model pptEr model ppt
Er model ppt
 
Sql commands
Sql commandsSql commands
Sql commands
 
DBMS: Types of keys
DBMS:  Types of keysDBMS:  Types of keys
DBMS: Types of keys
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
ER-Model-ER Diagram
ER-Model-ER DiagramER-Model-ER Diagram
ER-Model-ER Diagram
 
Data Designs (Software Engg.)
Data Designs (Software Engg.)Data Designs (Software Engg.)
Data Designs (Software Engg.)
 
Types of attributes (160210107054)
Types of attributes  (160210107054)Types of attributes  (160210107054)
Types of attributes (160210107054)
 
Types of keys in database management system by Dr. Kamal Gulati
Types of keys in database management system by Dr. Kamal GulatiTypes of keys in database management system by Dr. Kamal Gulati
Types of keys in database management system by Dr. Kamal Gulati
 
All data models in dbms
All data models in dbmsAll data models in dbms
All data models in dbms
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
 
The Relational Model
The Relational ModelThe Relational Model
The Relational Model
 
Enhanced Entity-Relationship (EER) Modeling
Enhanced Entity-Relationship (EER) ModelingEnhanced Entity-Relationship (EER) Modeling
Enhanced Entity-Relationship (EER) Modeling
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
Relational keys
Relational keysRelational keys
Relational keys
 
Types of keys dbms
Types of keys dbmsTypes of keys dbms
Types of keys dbms
 

Andere mochten auch (20)

Slide 5 keys
Slide 5 keysSlide 5 keys
Slide 5 keys
 
Audio Compression
Audio CompressionAudio Compression
Audio Compression
 
Database structure
Database structureDatabase structure
Database structure
 
N5 Computing Science HTML
N5 Computing Science HTMLN5 Computing Science HTML
N5 Computing Science HTML
 
Entity Relationship Diagrams
Entity Relationship DiagramsEntity Relationship Diagrams
Entity Relationship Diagrams
 
Technical Implementation: Software
Technical Implementation: SoftwareTechnical Implementation: Software
Technical Implementation: Software
 
Other web page aspects
Other web page aspectsOther web page aspects
Other web page aspects
 
Backing Storage
Backing StorageBacking Storage
Backing Storage
 
Searching and Sorting
Searching and SortingSearching and Sorting
Searching and Sorting
 
ISDD - Security Risks
ISDD - Security RisksISDD - Security Risks
ISDD - Security Risks
 
ISDD Sequential & Random Access
ISDD Sequential & Random AccessISDD Sequential & Random Access
ISDD Sequential & Random Access
 
ISDD Back Up Strategies
ISDD Back Up StrategiesISDD Back Up Strategies
ISDD Back Up Strategies
 
ISDD Media Types - File Compression
ISDD Media Types - File CompressionISDD Media Types - File Compression
ISDD Media Types - File Compression
 
ISDD Cloud and Internet Services
ISDD Cloud and Internet ServicesISDD Cloud and Internet Services
ISDD Cloud and Internet Services
 
Economic Impact of Computing Science
Economic Impact of Computing ScienceEconomic Impact of Computing Science
Economic Impact of Computing Science
 
ISDD Security Precautions
ISDD Security PrecautionsISDD Security Precautions
ISDD Security Precautions
 
ISDD Networking & Connectivity
ISDD Networking & ConnectivityISDD Networking & Connectivity
ISDD Networking & Connectivity
 
Normalisation
NormalisationNormalisation
Normalisation
 
ISDD Standard File Formats
ISDD Standard File FormatsISDD Standard File Formats
ISDD Standard File Formats
 
Higher Computing Science CSS
Higher Computing Science CSSHigher Computing Science CSS
Higher Computing Science CSS
 

Ähnlich wie Database Keys (20)

Database Keys
Database KeysDatabase Keys
Database Keys
 
ISDD Database Keys N5
ISDD Database Keys N5ISDD Database Keys N5
ISDD Database Keys N5
 
Doc 20191022-wa0041
Doc 20191022-wa0041Doc 20191022-wa0041
Doc 20191022-wa0041
 
Keys in Database
Keys in DatabaseKeys in Database
Keys in Database
 
Keys.pptx
Keys.pptxKeys.pptx
Keys.pptx
 
Dbms keysppt
Dbms keyspptDbms keysppt
Dbms keysppt
 
Dbms keys
Dbms keysDbms keys
Dbms keys
 
Presentation OF DBMS-2.pptx
Presentation OF DBMS-2.pptxPresentation OF DBMS-2.pptx
Presentation OF DBMS-2.pptx
 
Intro to Data warehousing lecture 12
Intro to Data warehousing   lecture 12Intro to Data warehousing   lecture 12
Intro to Data warehousing lecture 12
 
Dbms keys
Dbms keysDbms keys
Dbms keys
 
Keys in DBMS
Keys in DBMSKeys in DBMS
Keys in DBMS
 
Difference between fact tables and dimension tables
Difference between fact tables and dimension tablesDifference between fact tables and dimension tables
Difference between fact tables and dimension tables
 
2.2 keys
2.2 keys2.2 keys
2.2 keys
 
SQL_DBMS_KEYS.pptx
SQL_DBMS_KEYS.pptxSQL_DBMS_KEYS.pptx
SQL_DBMS_KEYS.pptx
 
B & c
B & cB & c
B & c
 
computer-210809080138.pdf
computer-210809080138.pdfcomputer-210809080138.pdf
computer-210809080138.pdf
 
Types of keys in dbms
Types of keys in dbmsTypes of keys in dbms
Types of keys in dbms
 
Key and its different types
Key and its different typesKey and its different types
Key and its different types
 
BIS03 Data Modelling - I
BIS03 Data Modelling - IBIS03 Data Modelling - I
BIS03 Data Modelling - I
 
DBMS-Unit-2.pptx
DBMS-Unit-2.pptxDBMS-Unit-2.pptx
DBMS-Unit-2.pptx
 

Mehr von Forrester High School (20)

Program Design
Program DesignProgram Design
Program Design
 
Database Evaluation
Database EvaluationDatabase Evaluation
Database Evaluation
 
Testing SQL
Testing SQLTesting SQL
Testing SQL
 
SQL
SQLSQL
SQL
 
Database Query Design
Database Query DesignDatabase Query Design
Database Query Design
 
Data Dictionary
Data DictionaryData Dictionary
Data Dictionary
 
Compound Keys
Compound KeysCompound Keys
Compound Keys
 
Entity Occurrence Diagrams
Entity Occurrence DiagramsEntity Occurrence Diagrams
Entity Occurrence Diagrams
 
Entity Relationship Diagrams
Entity Relationship DiagramsEntity Relationship Diagrams
Entity Relationship Diagrams
 
Database Analysis
Database AnalysisDatabase Analysis
Database Analysis
 
Software Evaluation
Software EvaluationSoftware Evaluation
Software Evaluation
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Standard Algorithms
Standard AlgorithmsStandard Algorithms
Standard Algorithms
 
File Handling
File HandlingFile Handling
File Handling
 
Python Predefined Functions
Python Predefined FunctionsPython Predefined Functions
Python Predefined Functions
 
Python Substrings
Python SubstringsPython Substrings
Python Substrings
 
Variable Scope
Variable ScopeVariable Scope
Variable Scope
 
Sub-programs
Sub-programsSub-programs
Sub-programs
 
Records in Python
Records in PythonRecords in Python
Records in Python
 
Parallel arrays in python
Parallel arrays in pythonParallel arrays in python
Parallel arrays in python
 

Kürzlich hochgeladen

Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research DiscourseAnita GoswamiGiri
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6Vanessa Camilleri
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
CHEST Proprioceptive neuromuscular facilitation.pptx
CHEST Proprioceptive neuromuscular facilitation.pptxCHEST Proprioceptive neuromuscular facilitation.pptx
CHEST Proprioceptive neuromuscular facilitation.pptxAneriPatwari
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesVijayaLaxmi84
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Developmentchesterberbo7
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptxmary850239
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQuiz Club NITW
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvRicaMaeCastro1
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1GloryAnnCastre1
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 

Kürzlich hochgeladen (20)

Scientific Writing :Research Discourse
Scientific  Writing :Research  DiscourseScientific  Writing :Research  Discourse
Scientific Writing :Research Discourse
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
CHEST Proprioceptive neuromuscular facilitation.pptx
CHEST Proprioceptive neuromuscular facilitation.pptxCHEST Proprioceptive neuromuscular facilitation.pptx
CHEST Proprioceptive neuromuscular facilitation.pptx
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their uses
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Development
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 

Database Keys

  • 1.
  • 2. Keys A key is a field or set of fields whose values uniquely identify a record. In this example, we could use SCN as a key because it uniquely identifies a pupil record. No other pupil can have the same SCN (Scottish Candidate Number). No other fields can uniquely identify each pupil record
  • 3. Candidate Key Any field or set of fields which can be considered as a key is known as a candidate key In this example, both Employee Number and Email are candidate keys, because both can uniquely identify the employee record in the table
  • 4. Primary Key The primary key is the candidate key which is chosen to be used In the example above, it's possible that the company may change the structure of staff email addresses. Given this, it would be better to use Employee Number as a primary key as this is less likely to change. A primary key consisting of only one field is known as an atomic key
  • 5. Compound Key It is possible in some tables that no one column can act as a primary key, and that a combination of columns are required to create the key. This is known as a compound key. Order ID cannot be a primary key as it does not uniquely identify a record Product ID cannot be a primary key as it does not uniquely identify a record
  • 6. Compound Key It is possible in some tables that no one column can act as a primary key, and that a combination of columns are required to create the key. This is known as a compound key. A compound key of Order ID and Product ID could be used because this is unique for each record.
  • 7. Surrogate Key A surrogate key is a special key which has no meaning or purpose other than to uniquely identify each record. Surrogate keys are often a combination of letters and numbers. A new column is created to be the primary key.
  • 8. Surrogate Key A surrogate key is a special key which has no meaning or purpose other than to uniquely identify each record. Surrogate keys are often a combination of letters and numbers. A new column is created to be the primary key. In this example, KTV have been interviewing passers-by for the evening news bulletin. The production team take a note of the interviewee's name and the duration of the interview. As these people are not related to KTV in anyway, a surrogate key must be created in order to uniquely identify them.
  • 9. Surrogate Key A surrogate key is a special key which has no meaning or purpose other than to uniquely identify each record. Surrogate keys are often a combination of letters and numbers. A new column is created to be the primary key. In this example, KTV have been interviewing passers-by for the evening news bulletin. The production team take a note of the interviewee's name and the duration of the interview. As these people are not related to KTV in anyway, a surrogate key must be created in order to uniquely identify them.
  • 10. Foreign Key A foreign key is a column which is added to one table to create a relationship with another table. In this example we have two tables, teachers and departments in a school. But there is no way to see which teacher works in which department.
  • 11. Foreign Key A foreign key is a column which is added to one table to create a relationship with another table. By adding the foreign key Department Code to the Teacher table, we can create a relationship between the two tables.
  • 12. Key Notation We represent primary keys by underlining them. We represent foreign keys with an asterisk.
  • 13. Key Notation We represent primary keys by underlining them. We represent foreign keys with an asterisk. young scot card (card_num, name, expiry_date, photo) pupil (candidate_num, forename, surname, dob, card_num*)
  • 14. Key Notation We represent primary keys by underlining them. We represent foreign keys with an asterisk. pupil (candidate_num, forename, surname, dob, postcode) exam (exam_id, subject, level, duration) result (candidate_num*, exam_id*, grade)
  • 15. Key Notation We represent primary keys by underlining them. We represent foreign keys with an asterisk. movie (movie_id, name, certificate, rating) cinema (cinema_id, city, telephone) screening (cinema*, movie*, date, time)