SlideShare a Scribd company logo
2
Most read
3
Most read
5
Most read
Introdaction to Python
Dr. Mohammed Kassim Page 41
Primary Key & Foreign Key - ERD
The primary key
The primary key is an attribute or a set of attributes that uniquely identify a specific
instance of an entity. Every entity in the data model must have a primary key
whose values uniquely identify instances of the entity.
To qualify as a primary key for an entity, an attribute must have the following
properties:
 It must have a non-null value for each instance of the entity
 The value must be unique for each instance of an entity
 The values must not change or become null during the life of each entity
 The primary key cannot have repeating values
Foreign key
A foreign key is an attribute that completes a relationship by identifying the parent
entity. Foreign keys provide a method for maintaining integrity in the data (called
Primary key
Foreign key
Introdaction to Python
Dr. Mohammed Kassim Page 42
Primary Key & Foreign Key - ERD
referential integrity) and for navigating between different instances of an entity.
Every relationship in the model must be supported by a foreign key.
Primary and foreign keys are the most basic components on which relational
theory is based. Each entity must have an attribute or attributes, the primary key,
whose values uniquely identify each instance of the entity. Every child entity must
have an attribute, the foreign key ,that completes the association with the parent
entity.
Example: design Entity Relationship diagram model for a college?
We have the following statements:
1. A college contains many departments
2. Each department can offer any number of courses
3. Many instructors can work in a department
4. An instructor can work only in one department
5. For each department there is a Head
6. Each instructor can take any number of courses
Introdaction to Python
Dr. Mohammed Kassim Page 43
Primary Key & Foreign Key - ERD
7. A course can be taken by only one instructor
8. A student can enroll for any number of courses
9. Each course can have any number of students
Step 1: Identify the Entities
What are the entities here?
1. Department
2. Course
3. Instructor
4. Student
Stem 2: Identify the relationships
1. One department offers many courses. But one particular course can be
offered by only one department. hence the cardinality between department
and course is One to Many (1:M)
2. One department has multiple instructors . But instructor belongs to only one
department. Hence the cardinality between department and instructor is One
to Many (1:M)
3. One course can be enrolled by many students and one student can enroll for
many courses. Hence the cardinality between course and student is Many to
Many (M:M)
4. One course is taught by only one instructor. But one instructor teaches many
courses. Hence the cardinality between course and instructor is Many to One
(M :1)
Introdaction to Python
Dr. Mohammed Kassim Page 44
Primary Key & Foreign Key - ERD
Step 3: Identify the key attributes
 "Departmen_Name" can identify a department uniquely.
 Course_ID is the key attribute for "Course" Entity.
 Student_ID is the key attribute for "Student" Entity.
 Instructor_ID is the key attribute for "Instructor" Entity.
Step 4: Identify other relevant attributes
For the department entity, other attributes are location
 For course entity, other attributes are course_name,duration
 For instructor entity, other attributes are first_name, last_name, phone
 For student entity, first_name, last_name, phone
Step 5: Draw complete ER diagram
By connecting all these details, we can now draw ER diagram as given below.
Introdaction to Python
Dr. Mohammed Kassim Page 45
Primary Key & Foreign Key - ERD
Entity Relationship (ER) model for a college
M
M
M
M

More Related Content

PPTX
Database Concepts and Terminologies
Ousman Faal
 
PPTX
ER Modeling and Introduction to RDBMS
Rubal Sagwal
 
PPTX
Database : Relational Data Model
Smriti Jain
 
PPTX
E-R Diagram of College Management Systems
Omprakash Chauhan
 
PPTX
Database systems - Chapter 1
shahab3
 
PPT
Enhanced E-R diagram
Mayank Jain
 
PPTX
DBMS-INTRODUCTION.pptx
DivyaKS12
 
PDF
Chapter 2 Relational Data Model-part1
Eddyzulham Mahluzydde
 
Database Concepts and Terminologies
Ousman Faal
 
ER Modeling and Introduction to RDBMS
Rubal Sagwal
 
Database : Relational Data Model
Smriti Jain
 
E-R Diagram of College Management Systems
Omprakash Chauhan
 
Database systems - Chapter 1
shahab3
 
Enhanced E-R diagram
Mayank Jain
 
DBMS-INTRODUCTION.pptx
DivyaKS12
 
Chapter 2 Relational Data Model-part1
Eddyzulham Mahluzydde
 

What's hot (20)

PPT
ER-Model-ER Diagram
Saranya Natarajan
 
PPT
Entity Relationship Diagram
Shakila Mahjabin
 
PDF
Packages - PL/SQL
Esmita Gupta
 
PDF
PL/SQL TRIGGERS
Lakshman Basnet
 
PDF
Create table
Nitesh Singh
 
PPTX
Sql fundamentals
Ravinder Kamboj
 
PPT
Constraints In Sql
Anurag
 
PPT
Data models
Usman Tariq
 
PPTX
DDL And DML
pnp @in
 
PPTX
Data types
Nokesh Prabhakar
 
PPTX
Tokens in C++
Mahender Boda
 
PDF
Object oriented databases
Sajith Ekanayaka
 
PPTX
File Management in Operating System
Janki Shah
 
PPT
Data Models.ppt
AnshikaGoel42
 
PDF
Introduction to Database Management System
Amiya9439793168
 
PPT
Database Management System Introduction
Smriti Jain
 
PPTX
Cursors
Priyanka Yadav
 
PPT
Unit 1 introduction to data structure
kalyanineve
 
PPT
2. Entity Relationship Model in DBMS
koolkampus
 
ER-Model-ER Diagram
Saranya Natarajan
 
Entity Relationship Diagram
Shakila Mahjabin
 
Packages - PL/SQL
Esmita Gupta
 
PL/SQL TRIGGERS
Lakshman Basnet
 
Create table
Nitesh Singh
 
Sql fundamentals
Ravinder Kamboj
 
Constraints In Sql
Anurag
 
Data models
Usman Tariq
 
DDL And DML
pnp @in
 
Data types
Nokesh Prabhakar
 
Tokens in C++
Mahender Boda
 
Object oriented databases
Sajith Ekanayaka
 
File Management in Operating System
Janki Shah
 
Data Models.ppt
AnshikaGoel42
 
Introduction to Database Management System
Amiya9439793168
 
Database Management System Introduction
Smriti Jain
 
Unit 1 introduction to data structure
kalyanineve
 
2. Entity Relationship Model in DBMS
koolkampus
 
Ad

Similar to Primary Key & Foreign Key part10 (20)

PPT
18306_lec-2 (1).ppt
IshuIswarya3
 
PPTX
Entity Relationship Management Moder: Introduction
gufranqureshi506
 
PDF
Databases - Unit 2.pdf
CynthiaAdzornu
 
PPT
ERD(2).ppt
Vijaykumar311275
 
PPTX
123
Divam Goyal
 
PPTX
Steps to create an ER Diagram, ER model Keys.pptx
yeshodhas
 
PPTX
Er diagrams presentation
Akanksha Jaiswal
 
PPTX
Er diagrams presentation
Akanksha Jaiswal
 
PPTX
rdbms3, dbms,dbms,rdbmssssssssssssssssssssssssssssssssss
VaibhavSrivastav52
 
PDF
erdiagramspresentation-150826044953-lva1-app6891.pdf
vinayakjadhav94
 
PDF
Example for ER diagram part11
DrMohammed Qassim
 
PPT
D I T211 Chapter 3
askme
 
PPT
chapter number 05Corrected local database.ppt
AzarHamid
 
PPTX
Data Models.pptx
CheriviralaNikhil
 
PPTX
DB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptx
ZahouAmel1
 
PDF
RDBMS ERD
Sarmad Ali
 
PPTX
er-models.pptx
UmmerFarooq24
 
PPTX
Er diagram
Sabana Maharjan
 
PPTX
Download different material from slide share
fanta teferi
 
PPT
Entity relationship diagram for dummies
www.myassignmenthelp.net
 
18306_lec-2 (1).ppt
IshuIswarya3
 
Entity Relationship Management Moder: Introduction
gufranqureshi506
 
Databases - Unit 2.pdf
CynthiaAdzornu
 
ERD(2).ppt
Vijaykumar311275
 
Steps to create an ER Diagram, ER model Keys.pptx
yeshodhas
 
Er diagrams presentation
Akanksha Jaiswal
 
Er diagrams presentation
Akanksha Jaiswal
 
rdbms3, dbms,dbms,rdbmssssssssssssssssssssssssssssssssss
VaibhavSrivastav52
 
erdiagramspresentation-150826044953-lva1-app6891.pdf
vinayakjadhav94
 
Example for ER diagram part11
DrMohammed Qassim
 
D I T211 Chapter 3
askme
 
chapter number 05Corrected local database.ppt
AzarHamid
 
Data Models.pptx
CheriviralaNikhil
 
DB-Lec1.pptxUpdatedpython.pptxUpdatedpython.pptx
ZahouAmel1
 
RDBMS ERD
Sarmad Ali
 
er-models.pptx
UmmerFarooq24
 
Er diagram
Sabana Maharjan
 
Download different material from slide share
fanta teferi
 
Entity relationship diagram for dummies
www.myassignmenthelp.net
 
Ad

More from DrMohammed Qassim (20)

PDF
Repatino code - hamming code (7,4) - chapter four
DrMohammed Qassim
 
PDF
Shannon code & shannon fano & huffman method - chapter three
DrMohammed Qassim
 
PDF
ٍSource Entropy - binary symmetric channe - chapter one - two
DrMohammed Qassim
 
PDF
(Win7) مقدمة في نظام التشغيل
DrMohammed Qassim
 
PDF
مقدمة في برمجة و تصميم الشبكات
DrMohammed Qassim
 
PDF
مقدمة حول الشبكات
DrMohammed Qassim
 
PDF
منهاج تحليل و تصميم نظم المعلومات
DrMohammed Qassim
 
PDF
منهاج بناء و تصميم مواقع الانترنيت
DrMohammed Qassim
 
PDF
مقدمة في قواعد البيانات
DrMohammed Qassim
 
PDF
System analysis part2
DrMohammed Qassim
 
PDF
Entity Relationship Diagram part9
DrMohammed Qassim
 
PDF
Activity Diagram part8
DrMohammed Qassim
 
PDF
Data flow diagram part7
DrMohammed Qassim
 
PDF
Data Flow Models part6
DrMohammed Qassim
 
PDF
Use Case Context Diagram part5
DrMohammed Qassim
 
PDF
Use Case Diagrams part4
DrMohammed Qassim
 
PDF
System Development Life Cycle part3
DrMohammed Qassim
 
PDF
Introduction to System analysis part1
DrMohammed Qassim
 
PDF
Introduction to Python
DrMohammed Qassim
 
PDF
(Protracted your system) حماية نظامك من الدخلاء
DrMohammed Qassim
 
Repatino code - hamming code (7,4) - chapter four
DrMohammed Qassim
 
Shannon code & shannon fano & huffman method - chapter three
DrMohammed Qassim
 
ٍSource Entropy - binary symmetric channe - chapter one - two
DrMohammed Qassim
 
(Win7) مقدمة في نظام التشغيل
DrMohammed Qassim
 
مقدمة في برمجة و تصميم الشبكات
DrMohammed Qassim
 
مقدمة حول الشبكات
DrMohammed Qassim
 
منهاج تحليل و تصميم نظم المعلومات
DrMohammed Qassim
 
منهاج بناء و تصميم مواقع الانترنيت
DrMohammed Qassim
 
مقدمة في قواعد البيانات
DrMohammed Qassim
 
System analysis part2
DrMohammed Qassim
 
Entity Relationship Diagram part9
DrMohammed Qassim
 
Activity Diagram part8
DrMohammed Qassim
 
Data flow diagram part7
DrMohammed Qassim
 
Data Flow Models part6
DrMohammed Qassim
 
Use Case Context Diagram part5
DrMohammed Qassim
 
Use Case Diagrams part4
DrMohammed Qassim
 
System Development Life Cycle part3
DrMohammed Qassim
 
Introduction to System analysis part1
DrMohammed Qassim
 
Introduction to Python
DrMohammed Qassim
 
(Protracted your system) حماية نظامك من الدخلاء
DrMohammed Qassim
 

Recently uploaded (20)

PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 

Primary Key & Foreign Key part10

  • 1. Introdaction to Python Dr. Mohammed Kassim Page 41 Primary Key & Foreign Key - ERD The primary key The primary key is an attribute or a set of attributes that uniquely identify a specific instance of an entity. Every entity in the data model must have a primary key whose values uniquely identify instances of the entity. To qualify as a primary key for an entity, an attribute must have the following properties:  It must have a non-null value for each instance of the entity  The value must be unique for each instance of an entity  The values must not change or become null during the life of each entity  The primary key cannot have repeating values Foreign key A foreign key is an attribute that completes a relationship by identifying the parent entity. Foreign keys provide a method for maintaining integrity in the data (called Primary key Foreign key
  • 2. Introdaction to Python Dr. Mohammed Kassim Page 42 Primary Key & Foreign Key - ERD referential integrity) and for navigating between different instances of an entity. Every relationship in the model must be supported by a foreign key. Primary and foreign keys are the most basic components on which relational theory is based. Each entity must have an attribute or attributes, the primary key, whose values uniquely identify each instance of the entity. Every child entity must have an attribute, the foreign key ,that completes the association with the parent entity. Example: design Entity Relationship diagram model for a college? We have the following statements: 1. A college contains many departments 2. Each department can offer any number of courses 3. Many instructors can work in a department 4. An instructor can work only in one department 5. For each department there is a Head 6. Each instructor can take any number of courses
  • 3. Introdaction to Python Dr. Mohammed Kassim Page 43 Primary Key & Foreign Key - ERD 7. A course can be taken by only one instructor 8. A student can enroll for any number of courses 9. Each course can have any number of students Step 1: Identify the Entities What are the entities here? 1. Department 2. Course 3. Instructor 4. Student Stem 2: Identify the relationships 1. One department offers many courses. But one particular course can be offered by only one department. hence the cardinality between department and course is One to Many (1:M) 2. One department has multiple instructors . But instructor belongs to only one department. Hence the cardinality between department and instructor is One to Many (1:M) 3. One course can be enrolled by many students and one student can enroll for many courses. Hence the cardinality between course and student is Many to Many (M:M) 4. One course is taught by only one instructor. But one instructor teaches many courses. Hence the cardinality between course and instructor is Many to One (M :1)
  • 4. Introdaction to Python Dr. Mohammed Kassim Page 44 Primary Key & Foreign Key - ERD Step 3: Identify the key attributes  "Departmen_Name" can identify a department uniquely.  Course_ID is the key attribute for "Course" Entity.  Student_ID is the key attribute for "Student" Entity.  Instructor_ID is the key attribute for "Instructor" Entity. Step 4: Identify other relevant attributes For the department entity, other attributes are location  For course entity, other attributes are course_name,duration  For instructor entity, other attributes are first_name, last_name, phone  For student entity, first_name, last_name, phone Step 5: Draw complete ER diagram By connecting all these details, we can now draw ER diagram as given below.
  • 5. Introdaction to Python Dr. Mohammed Kassim Page 45 Primary Key & Foreign Key - ERD Entity Relationship (ER) model for a college M M M M