SlideShare ist ein Scribd-Unternehmen logo
1 von 17
ERD Cardinality
OOD Inge Powell
ERD Cardinality
 When

we show relationships between
tables we need to show the cardinality.
 Depending on the data we are storing
there are several options to choose
from.
 If using Visio to create a diagram, it
takes its initial value from the database
store.
Erd Cardinality
 The

cardinality relationship is shown with
lines between two entities to indicate a
relationship.
Entity A

 This

Entity B

line denotes that there is a
relationship between the entities.
ERD Cardinality
 The

ENDS of these lines denote the cardinality
to that entity.
Entity A

 This

Entity B

is a ‘One to One’ relationship.
 This means that Entity A will relate to only one
of Entity B.
 And Entity B will relate to only one of Entity A
Erd Cardinality
 Here

is an example..
Bus

Driver

 One

Driver drives just one Bus.
 One Bus has just one Driver.
 The records might be held like this:
Bus
Bus

PK BusID
PK BusID
Colour
Colour
NoOfSeats
NoOfSeats
FK DriverID
FK DriverID

Driver
Driver

PK DriverID
PK DriverID
Name
Name
Points
Points
FK BusID
FK BusID
ERD Cardinality
 The

use of ‘Crows Feet’.
Entity A

 This

Entity B

is a ‘One to Many’ relationship.
 This means that Entity A will relate to many of
Entity B.
 And Entity B will relate to only one of Entity A.
Erd Cardinality
 Here

is an example.

Customer

Order

 One

Customer may have many orders.
 One Order is for just one Customer.
 The records might be held like this:
Customer
Customer

PK CustID
PK CustID
Name
Name
Address
Address

TelNo
TelNo

Order
Order

PK OrderNo
PK OrderNo
Date
Date
FK CustID
FK CustID
ERD Cardinality
 The

use of ‘Crows Feet’.

Entity A

Entity B

 This

is a ‘Many to One’ relationship.
 This means that Entity A will relate to only one
of Entity B.
 And Entity B will relate to many of Entity A.


(We still tend to refer to as a one to many, just the
other way round from B to A)
Erd Cardinality
 Here

is an example.
Product

Supplier

 One

Product will have just one Supplier.
 One Supplier will supply many Products.
 The records might be held like this:
Product
Product
PK ProdID
PK ProdID
PName
PName
Price
Price

Supplier
Supplier
PK SuppID
PK SuppID
Name
Name
Address
Address
TelNo
TelNo
ERD Cardinality
 The

use of ‘Crows Feet’.
Entity A

 This

Entity B

is a ‘Many to Many’ relationship.
 This means that Entity A will relate to many of
Entity B.
 And Entity B will relate to many of Entity A.
ERD Cardinality
 Many

to Many - This can cause problems with
data, as we can’t pinpoint the link.
Entity A

Entity B

 Imagine

this, a Lender can borrow many
Books. But a Book can be borrowed by more
than one Lender.
Lender

Book
ERD Cardinality
 How

do we know who has each individual
book?
Lender

Book

 Also

when we look at the data, how will we
store this?
Lender
Lender

PK LenderID
PK LenderID
Name
Name
Address
Address
FK BookID
FK BookID
FK BookID
FK BookID
FK BookID

Book
Book

PK BookID
PK BookID

FK
FK

Title
Title
Author
Author

LenderID
LenderID
ERD Cardinality
 To

manage the many to many relationship, the
data would need to keep growing.

 This

still causes problems,
 Who has the book now?
 This
 We

is silly!!

can resolve this
 By adding a link table.

Book
Book

PK BookID
PK BookID
Title
Title
Author
Author
FK LenderID
FK LenderID
FK LenderID
FK LenderID
FK LenderID
FK LenderID
FK LenderID
FK LenderID
FK LenderID
FK LenderID
FK LenderID
FK LenderID
FK LenderID
FK LenderID
FK LenderID
FK LenderID
FK LenderID
FK LenderID
FK LenderID
ERD Cardinality
 To

resolve a many to many relationship.
Entity A

 We

Entity B

resolve it by adding a link table.

Entity A

 This

Entity C

Entity B

means we now have two manageable
one to many relationships instead.
ERD Cardinality
 The

resolved many to many relationship.

Lender

LendRecord

Book

 One

lender can have several LendRecords
 One LendRecord is for just one Lender
 One

Book can have several LendRecords
 One LendRecord is for just one Book
ERD Cardinality
 Here

is the resolved example.

Lender

LendRecord

Book

 The

data for this system might look something
like this:
Lender
Lender

PK LenderID
PK LenderID
Name
Name
Address
Address

Book
Book
LendRecor
LendRecor
d
d
PK RecordID
PK RecordID
FK BookID
FK BookID
FK LenderID
FK LenderID

PK BookID
PK BookID
Title
Title
Author
Author
ERD Cardinality
 The

LendRecord record could be deleted
when the book is returned.
Lender

 Or

LendRecord

Book

fields added to identify the current loan.

Lender
Lender

PK LenderID
PK LenderID
Name
Name
Address
Address

Book
Book
LendRecor
LendRecor
d
d
PK RecordID
PK RecordID
FK BookID
FK BookID
FK LenderID
FK LenderID
OnLoanYN
OnLoanYN
Date

PK BookID
PK BookID
Title
Title
Author
Author

Weitere ähnliche Inhalte

Was ist angesagt?

2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMSkoolkampus
 
DBMS Question bank
DBMS Question bankDBMS Question bank
DBMS Question bankSara Sahu
 
Er model ppt
Er model pptEr model ppt
Er model pptPihu Goel
 
Introduction to Graph Databases
Introduction to Graph DatabasesIntroduction to Graph Databases
Introduction to Graph DatabasesMax De Marzi
 
Map Reduce data types and formats
Map Reduce data types and formatsMap Reduce data types and formats
Map Reduce data types and formatsVigen Sahakyan
 
Biomedical Entity Linking - Introduction, approaches, challenges
Biomedical Entity Linking - Introduction, approaches, challengesBiomedical Entity Linking - Introduction, approaches, challenges
Biomedical Entity Linking - Introduction, approaches, challengesAnja Pilz
 
Big Data: Its Characteristics And Architecture Capabilities
Big Data: Its Characteristics And Architecture CapabilitiesBig Data: Its Characteristics And Architecture Capabilities
Big Data: Its Characteristics And Architecture CapabilitiesAshraf Uddin
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship DiagramShakila Mahjabin
 
Data preprocessing
Data preprocessingData preprocessing
Data preprocessingankur bhalla
 
E_R-Diagram (2).pptx
E_R-Diagram (2).pptxE_R-Diagram (2).pptx
E_R-Diagram (2).pptxsandeep54552
 
Lect 2 getting to know your data
Lect 2 getting to know your dataLect 2 getting to know your data
Lect 2 getting to know your datahktripathy
 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization TechniquesNishant Munjal
 
Database Design
Database DesignDatabase Design
Database Designlearnt
 
Error handling and debugging in vb
Error handling and debugging in vbError handling and debugging in vb
Error handling and debugging in vbSalim M
 
7 key principles of effective data visualization
7 key principles of effective data visualization7 key principles of effective data visualization
7 key principles of effective data visualizationCountants
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship ModelNeil Neelesh
 
Clinical Healthcare Data Analytics
Clinical Healthcare Data AnalyticsClinical Healthcare Data Analytics
Clinical Healthcare Data Analyticsdansouk
 

Was ist angesagt? (20)

2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS
 
DBMS Question bank
DBMS Question bankDBMS Question bank
DBMS Question bank
 
Er model ppt
Er model pptEr model ppt
Er model ppt
 
Introduction to Graph Databases
Introduction to Graph DatabasesIntroduction to Graph Databases
Introduction to Graph Databases
 
Er diagram
Er diagramEr diagram
Er diagram
 
Map Reduce data types and formats
Map Reduce data types and formatsMap Reduce data types and formats
Map Reduce data types and formats
 
Biomedical Entity Linking - Introduction, approaches, challenges
Biomedical Entity Linking - Introduction, approaches, challengesBiomedical Entity Linking - Introduction, approaches, challenges
Biomedical Entity Linking - Introduction, approaches, challenges
 
Big Data: Its Characteristics And Architecture Capabilities
Big Data: Its Characteristics And Architecture CapabilitiesBig Data: Its Characteristics And Architecture Capabilities
Big Data: Its Characteristics And Architecture Capabilities
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 
Data preprocessing
Data preprocessingData preprocessing
Data preprocessing
 
E_R-Diagram (2).pptx
E_R-Diagram (2).pptxE_R-Diagram (2).pptx
E_R-Diagram (2).pptx
 
Lect 2 getting to know your data
Lect 2 getting to know your dataLect 2 getting to know your data
Lect 2 getting to know your data
 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization Techniques
 
Database Design
Database DesignDatabase Design
Database Design
 
Inverted index
Inverted indexInverted index
Inverted index
 
And or graph
And or graphAnd or graph
And or graph
 
Error handling and debugging in vb
Error handling and debugging in vbError handling and debugging in vb
Error handling and debugging in vb
 
7 key principles of effective data visualization
7 key principles of effective data visualization7 key principles of effective data visualization
7 key principles of effective data visualization
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 
Clinical Healthcare Data Analytics
Clinical Healthcare Data AnalyticsClinical Healthcare Data Analytics
Clinical Healthcare Data Analytics
 

Andere mochten auch

Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)Mudasir Qazi
 
How to Draw an Effective ER diagram
How to Draw an Effective ER diagramHow to Draw an Effective ER diagram
How to Draw an Effective ER diagramTech_MX
 
Proses pembentukan malaysia
Proses pembentukan malaysiaProses pembentukan malaysia
Proses pembentukan malaysiamunnianwar
 
Ciri – ciri negara
Ciri – ciri negara Ciri – ciri negara
Ciri – ciri negara munnianwar
 
Ciri ciri Negara Malaysia
Ciri ciri  Negara MalaysiaCiri ciri  Negara Malaysia
Ciri ciri Negara Malaysiamunnianwar
 
Badan Perundangan Parlimen
Badan Perundangan ParlimenBadan Perundangan Parlimen
Badan Perundangan Parlimenmunnianwar
 
Majlis raja raja
Majlis raja rajaMajlis raja raja
Majlis raja rajamunnianwar
 
Yang di pertuan agong
Yang di pertuan agongYang di pertuan agong
Yang di pertuan agongmunnianwar
 
Kerajaan negeri
Kerajaan negeriKerajaan negeri
Kerajaan negerimunnianwar
 

Andere mochten auch (12)

Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)
 
How to Draw an Effective ER diagram
How to Draw an Effective ER diagramHow to Draw an Effective ER diagram
How to Draw an Effective ER diagram
 
Proses pembentukan malaysia
Proses pembentukan malaysiaProses pembentukan malaysia
Proses pembentukan malaysia
 
Perlembagaan
PerlembagaanPerlembagaan
Perlembagaan
 
Ciri – ciri negara
Ciri – ciri negara Ciri – ciri negara
Ciri – ciri negara
 
Ciri ciri Negara Malaysia
Ciri ciri  Negara MalaysiaCiri ciri  Negara Malaysia
Ciri ciri Negara Malaysia
 
Badan Perundangan Parlimen
Badan Perundangan ParlimenBadan Perundangan Parlimen
Badan Perundangan Parlimen
 
Majlis raja raja
Majlis raja rajaMajlis raja raja
Majlis raja raja
 
Yang di pertuan agong
Yang di pertuan agongYang di pertuan agong
Yang di pertuan agong
 
Kabinet
KabinetKabinet
Kabinet
 
Kerajaan negeri
Kerajaan negeriKerajaan negeri
Kerajaan negeri
 
Kementerian
KementerianKementerian
Kementerian
 

Kürzlich hochgeladen

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 

Kürzlich hochgeladen (20)

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 

Erd cardinality

  • 2. ERD Cardinality  When we show relationships between tables we need to show the cardinality.  Depending on the data we are storing there are several options to choose from.  If using Visio to create a diagram, it takes its initial value from the database store.
  • 3. Erd Cardinality  The cardinality relationship is shown with lines between two entities to indicate a relationship. Entity A  This Entity B line denotes that there is a relationship between the entities.
  • 4. ERD Cardinality  The ENDS of these lines denote the cardinality to that entity. Entity A  This Entity B is a ‘One to One’ relationship.  This means that Entity A will relate to only one of Entity B.  And Entity B will relate to only one of Entity A
  • 5. Erd Cardinality  Here is an example.. Bus Driver  One Driver drives just one Bus.  One Bus has just one Driver.  The records might be held like this: Bus Bus PK BusID PK BusID Colour Colour NoOfSeats NoOfSeats FK DriverID FK DriverID Driver Driver PK DriverID PK DriverID Name Name Points Points FK BusID FK BusID
  • 6. ERD Cardinality  The use of ‘Crows Feet’. Entity A  This Entity B is a ‘One to Many’ relationship.  This means that Entity A will relate to many of Entity B.  And Entity B will relate to only one of Entity A.
  • 7. Erd Cardinality  Here is an example. Customer Order  One Customer may have many orders.  One Order is for just one Customer.  The records might be held like this: Customer Customer PK CustID PK CustID Name Name Address Address TelNo TelNo Order Order PK OrderNo PK OrderNo Date Date FK CustID FK CustID
  • 8. ERD Cardinality  The use of ‘Crows Feet’. Entity A Entity B  This is a ‘Many to One’ relationship.  This means that Entity A will relate to only one of Entity B.  And Entity B will relate to many of Entity A.  (We still tend to refer to as a one to many, just the other way round from B to A)
  • 9. Erd Cardinality  Here is an example. Product Supplier  One Product will have just one Supplier.  One Supplier will supply many Products.  The records might be held like this: Product Product PK ProdID PK ProdID PName PName Price Price Supplier Supplier PK SuppID PK SuppID Name Name Address Address TelNo TelNo
  • 10. ERD Cardinality  The use of ‘Crows Feet’. Entity A  This Entity B is a ‘Many to Many’ relationship.  This means that Entity A will relate to many of Entity B.  And Entity B will relate to many of Entity A.
  • 11. ERD Cardinality  Many to Many - This can cause problems with data, as we can’t pinpoint the link. Entity A Entity B  Imagine this, a Lender can borrow many Books. But a Book can be borrowed by more than one Lender. Lender Book
  • 12. ERD Cardinality  How do we know who has each individual book? Lender Book  Also when we look at the data, how will we store this? Lender Lender PK LenderID PK LenderID Name Name Address Address FK BookID FK BookID FK BookID FK BookID FK BookID Book Book PK BookID PK BookID FK FK Title Title Author Author LenderID LenderID
  • 13. ERD Cardinality  To manage the many to many relationship, the data would need to keep growing.  This still causes problems,  Who has the book now?  This  We is silly!! can resolve this  By adding a link table. Book Book PK BookID PK BookID Title Title Author Author FK LenderID FK LenderID FK LenderID FK LenderID FK LenderID FK LenderID FK LenderID FK LenderID FK LenderID FK LenderID FK LenderID FK LenderID FK LenderID FK LenderID FK LenderID FK LenderID FK LenderID FK LenderID FK LenderID
  • 14. ERD Cardinality  To resolve a many to many relationship. Entity A  We Entity B resolve it by adding a link table. Entity A  This Entity C Entity B means we now have two manageable one to many relationships instead.
  • 15. ERD Cardinality  The resolved many to many relationship. Lender LendRecord Book  One lender can have several LendRecords  One LendRecord is for just one Lender  One Book can have several LendRecords  One LendRecord is for just one Book
  • 16. ERD Cardinality  Here is the resolved example. Lender LendRecord Book  The data for this system might look something like this: Lender Lender PK LenderID PK LenderID Name Name Address Address Book Book LendRecor LendRecor d d PK RecordID PK RecordID FK BookID FK BookID FK LenderID FK LenderID PK BookID PK BookID Title Title Author Author
  • 17. ERD Cardinality  The LendRecord record could be deleted when the book is returned. Lender  Or LendRecord Book fields added to identify the current loan. Lender Lender PK LenderID PK LenderID Name Name Address Address Book Book LendRecor LendRecor d d PK RecordID PK RecordID FK BookID FK BookID FK LenderID FK LenderID OnLoanYN OnLoanYN Date PK BookID PK BookID Title Title Author Author