SlideShare une entreprise Scribd logo
1  sur  30
Télécharger pour lire hors ligne
1
Entity Relationship Diagram
Objectives:
• (b) identify the entity set, attribute, relational set and
cardinality in data modelling;
• (c) use E-R diagrams to model data;
• (d) map the E-R diagram to a relational model: one-to-
one, one-to-many and many-to-many binary relationships;
2
Entity-Relationship (ER) Diagram
• Entity Relationship (ER) Diagram
– A detailed, logical representation of the entities,
associations and data elements for an organization or
business
• Notation uses three main constructs
– Data entities
– Relationships
– Attributes Chen Model &
Crow’s Foot
Model
Person, place, object, event
or concept about which data
is to be maintained
named property or
characteristic of an
entity
Association
between the
instances of one or
more entity types
Represents a set or collection of
objects in the real world that
share the same properties
Chen Notation
EntityName Verb Phrase AttributeName
Crow’s Foot Notation
EntityName
Entity Attribute
EntityName
List of
Attributes
Relationship
Verb phrase
Acceptable
5
Entities
• Examples of entities:
– Person: EMPLOYEE, STUDENT, PATIENT
– Place: STORE, WAREHOUSE
– Object: MACHINE, PRODUCT, CAR
– Event: SALE,REGISTRATION, RENEWAL
– Concept: ACCOUNT, COURSE
• Guidelines for naming and defining entity types:
– An entity type name is a singular noun
– An entity type should be descriptive and specific
– An entity name should be concise
– Event entity types should be named for the result of the event, not
the activity or process of the event.
6
Attributes
• Example of entity types and associated attributes:
STUDENT: Student_ID, Student_Name, Home_Address,
Phone_Number, Major
• Guidelines for naming attributes:
– An attribute name is a noun.
– An attribute name should be unique
– To make an attribute name unique and clear, each attribute name
should follow a standard format
– Similar attributes of different entity types should use similar but
distinguishing names.
7
2.2.1 Identifier Attributes
• Candidate key
– Attribute (or combination of attributes) that uniquely
identifies each instance of an entity type
– Some entities may have more than one candidate key
• Ex: A candidate key for EMPLOYEE is Employee_ID, a second is
the combination of Employee_Name and Address.
• If there is more than one candidate key, need to make a choice.
• Identifier
– A candidate key that has been selected as the unique
identifying characteristic for an entity type
8
2.2.2 Referential Attributes
Name IdNum DeptID Email
Ali 105 LG ali@a.com
Mary 106 IT mary@a.com
John 107 ENG john@a.com
Lim 108 IT lim@a.com
Instance of Lecturer.
Referential attribute: Ties the lecturer entity to
another entity that is department.
• Make Reference to another instance in another table
9
Example
Staff
StaffID
Name Gender
IC
Staff
StaffID
Name
Gender
IC
PK
10
Relationships
 Associations between instances of one or more entity types that is of interest
 Given a name that describes its function.
• relationship name is an active or a passive verb.
Author Book
Relationship name:
writes
An author writes one or more books
A book can be written by one or more authors.
11
Degree of Relationships
• Degree: number of entity types that participate in a relationship
• Three cases
– Unary: between two instances of one entity type
– Binary: between the instances of two entity types
– Ternary: among the instances of three entity types
12
2.4 Cardinality and Connectivity
• Relationships can be classified as either
• one – to – one
• one – to – many
• many – to –many
• Cardinality : minimum and maximum number of
instances of Entity B that can (or must be)
associated with each instance of entity A.
Connectivity
13
Cardinality and Connectivity
Professor Class
teaches
A professor teaches class OR
A class is taught by professor
How Many??
Professor Class
teaches
14
2.4 Cardinality and Connectivity
Professor Class
teaches
Professor Class
teaches
1 M
Connectivity
Connectivity
(1,1)
(1,1)
(1,4)
(1,4)
Cardinality
Cardinality
15
2.4.1 Connectivity
• Chen Model
– 1 to represent one.
– M to represent many
• Crow’s Foot
many
One
One or many
1
M
Mandatory one , means (1,1)
Optional? – we’ll see after this
16
2.5 Binary Relationships
• 1:M relationship
– Relational modeling ideal
– Should be the norm in any relational database design
The 1: M relationship between PAINTER and PAINTING
The Implemented 1:M relationship between PAINTER and PAINTING
18
2.5 Binary Relationships
• 1:1 relationship
– Should be rare in any relational database design
– A single entity instance in one entity class is related to a single entity
instance in another entity class
– Could indicate that two entities actually belong in the same table
The 1:1 Relationship Between PROFESSOR and DEPARTMENT
The Implemented
1:1 Relationship
Between
PROFESSOR
and
DEPARTMENT
21
2.5 Binary Relationships
• M:N relationships
– Must be avoided because they lead to data redundancies.
– Can be implemented by breaking it up to produce a set of 1:M
relationships
– Can avoid problems inherent to M:N relationship by creating a
composite entity or bridge entity
• This will be used to link the tables that were originally related
in a M:N relationship
• The composite entity structure includes-as foreign keys-at
least the primary keys of the tables that are to be linked.
The M:N Relationship Between STUDENT and CLASS
This CANNOT be implemented as shown next…..
Bowser
Smithson
Accounting 1 (ACCT-211)
Intro to Microcomputing (CIS-220)
Intro to Statistics (QM-261)
The tables have many redundancies!!
+ CLASS_CODE
CLASS_CODE
+ STU_NUM
Changing the M:N relationship to TWO 1:M relationships
Converting the M:N relationship into TWO 1:M relationships
Foreign keys reference the primary keys in the
other tables of which it has a relationship with
The database designer has 2 main options to
define a composite table’s primary key:
either
use the combination of those foreign
keys or create a new primary key.
26
Mandatory vs. Optional Cardinalities
• Specifies whether an instance must exist or can be absent in the
relationship
Lecturer Class
handles
A Lecturer may handle zero or many classes.
A class is handled by one and only one Lecturer.
Optional
Mandatory
(0,N)
(1,1)
Lecturer Class
(0,N) (1,1)
handles
1
M
27
How to Evaluate a Data Model?
• A good data model has the following:
– Accuracy and completeness
– Non redundancy
– Enforcement of business rules
– Data Reusability
– Stability and Flexibility
– Communication Effectiveness
– Simplicity
28
A Common Mistake
Modeling the business processes or functions
instead of the data.
What data we want to keep??
We are interested in modeling the data,
NOT the processes or functions that use
or generate those data.
29
Example:
Member Books
Searches
M N
Is this part of the data requirement?
Are we interested to know the books searched by the members?
If answer is NO, then DO NOT include that as a relationship.
Use other appropriate diagramming techniques to capture the business
processes such as Data Flow Diagram.
Do not mix up the use of ER Modeling with DFD.
30
~The END~
Q & A

Contenu connexe

Tendances

Basic Concept Of Database Management System (DBMS) [Presentation Slide]
Basic Concept Of Database Management System (DBMS) [Presentation Slide]Basic Concept Of Database Management System (DBMS) [Presentation Slide]
Basic Concept Of Database Management System (DBMS) [Presentation Slide]Atik Israk
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)Sabana Maharjan
 
All data models in dbms
All data models in dbmsAll data models in dbms
All data models in dbmsNaresh Kumar
 
Type of database models
Type of database modelsType of database models
Type of database modelsSanthiNivas
 
Data Models [DATABASE SYSTEMS: Design, Implementation, and Management]
Data Models [DATABASE SYSTEMS: Design, Implementation, and Management]Data Models [DATABASE SYSTEMS: Design, Implementation, and Management]
Data Models [DATABASE SYSTEMS: Design, Implementation, and Management]Usman Tariq
 
Introduction of DBMS
Introduction of DBMSIntroduction of DBMS
Introduction of DBMSYouQue ™
 
Database management system presentation
Database management system presentationDatabase management system presentation
Database management system presentationsameerraaj
 
Lecture 04 normalization
Lecture 04 normalization Lecture 04 normalization
Lecture 04 normalization emailharmeet
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database ModelShishir Aryal
 
Entity Relationship Modelling
Entity Relationship ModellingEntity Relationship Modelling
Entity Relationship ModellingBhandari Nawaraj
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model IntroductionNishant Munjal
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship DiagramShakila Mahjabin
 
Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)Mudasir Qazi
 
TID Chapter 10 Introduction To Database
TID Chapter 10 Introduction To DatabaseTID Chapter 10 Introduction To Database
TID Chapter 10 Introduction To DatabaseWanBK Leo
 
Slide 2 data models
Slide 2 data modelsSlide 2 data models
Slide 2 data modelsVisakh V
 

Tendances (20)

Basic Concept Of Database Management System (DBMS) [Presentation Slide]
Basic Concept Of Database Management System (DBMS) [Presentation Slide]Basic Concept Of Database Management System (DBMS) [Presentation Slide]
Basic Concept Of Database Management System (DBMS) [Presentation Slide]
 
ER MODEL
ER MODELER MODEL
ER MODEL
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 
All data models in dbms
All data models in dbmsAll data models in dbms
All data models in dbms
 
Type of database models
Type of database modelsType of database models
Type of database models
 
Data Models [DATABASE SYSTEMS: Design, Implementation, and Management]
Data Models [DATABASE SYSTEMS: Design, Implementation, and Management]Data Models [DATABASE SYSTEMS: Design, Implementation, and Management]
Data Models [DATABASE SYSTEMS: Design, Implementation, and Management]
 
Introduction of DBMS
Introduction of DBMSIntroduction of DBMS
Introduction of DBMS
 
Database management system presentation
Database management system presentationDatabase management system presentation
Database management system presentation
 
Lecture 04 normalization
Lecture 04 normalization Lecture 04 normalization
Lecture 04 normalization
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database Model
 
Entity Relationship Modelling
Entity Relationship ModellingEntity Relationship Modelling
Entity Relationship Modelling
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 
Relational model
Relational modelRelational model
Relational model
 
Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)Database - Entity Relationship Diagram (ERD)
Database - Entity Relationship Diagram (ERD)
 
TID Chapter 10 Introduction To Database
TID Chapter 10 Introduction To DatabaseTID Chapter 10 Introduction To Database
TID Chapter 10 Introduction To Database
 
Slide 2 data models
Slide 2 data modelsSlide 2 data models
Slide 2 data models
 
Database Normalization by Dr. Kamal Gulati
Database Normalization by Dr. Kamal GulatiDatabase Normalization by Dr. Kamal Gulati
Database Normalization by Dr. Kamal Gulati
 
Different data models
Different data modelsDifferent data models
Different data models
 
Normalization
NormalizationNormalization
Normalization
 

Similaire à entity-relationship-diagram-chen-&-crow -model.ppt

Similaire à entity-relationship-diagram-chen-&-crow -model.ppt (20)

Entity relationship modelling - DE L300
Entity relationship modelling - DE L300Entity relationship modelling - DE L300
Entity relationship modelling - DE L300
 
ERD.ppt
ERD.pptERD.ppt
ERD.ppt
 
ERD.ppt
ERD.pptERD.ppt
ERD.ppt
 
Revision ch 3
Revision ch 3Revision ch 3
Revision ch 3
 
entityrelationshipmodel.pptx
entityrelationshipmodel.pptxentityrelationshipmodel.pptx
entityrelationshipmodel.pptx
 
2 er
2 er2 er
2 er
 
18306_lec-2 (1).ppt
18306_lec-2 (1).ppt18306_lec-2 (1).ppt
18306_lec-2 (1).ppt
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 
Database part3-
Database part3-Database part3-
Database part3-
 
Erd1
Erd1Erd1
Erd1
 
RDBMS ERD
RDBMS ERDRDBMS ERD
RDBMS ERD
 
Entityrelationshipmodel
EntityrelationshipmodelEntityrelationshipmodel
Entityrelationshipmodel
 
ER model
ER modelER model
ER model
 
Download different material from slide share
Download different material from slide shareDownload different material from slide share
Download different material from slide share
 
10287 lecture5(2)
10287 lecture5(2)10287 lecture5(2)
10287 lecture5(2)
 
ER MODEL.pptx
ER MODEL.pptxER MODEL.pptx
ER MODEL.pptx
 
Week 4 The Relational Data Model & The Entity Relationship Data Model
Week 4 The Relational Data Model & The Entity Relationship Data ModelWeek 4 The Relational Data Model & The Entity Relationship Data Model
Week 4 The Relational Data Model & The Entity Relationship Data Model
 
Db lec 02_new
Db lec 02_newDb lec 02_new
Db lec 02_new
 
Data modeling
Data modelingData modeling
Data modeling
 
ERD(2).ppt
ERD(2).pptERD(2).ppt
ERD(2).ppt
 

Dernier

Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.EnglishCEIPdeSigeiro
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxraviapr7
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.raviapr7
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxheathfieldcps1
 
EBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting BlEBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting BlDr. Bruce A. Johnson
 
Work Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sashaWork Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sashasashalaycock03
 
Protein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptxProtein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptxvidhisharma994099
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17Celine George
 
Department of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdfDepartment of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdfMohonDas
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxraviapr7
 
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptxSlides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptxCapitolTechU
 
A gentle introduction to Artificial Intelligence
A gentle introduction to Artificial IntelligenceA gentle introduction to Artificial Intelligence
A gentle introduction to Artificial IntelligenceApostolos Syropoulos
 
Ultra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxUltra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxDr. Asif Anas
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfMohonDas
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxAditiChauhan701637
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesCeline George
 
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptxSOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptxSyedNadeemGillANi
 
Optical Fibre and It's Applications.pptx
Optical Fibre and It's Applications.pptxOptical Fibre and It's Applications.pptx
Optical Fibre and It's Applications.pptxPurva Nikam
 

Dernier (20)

Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptx
 
Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.Drug Information Services- DIC and Sources.
Drug Information Services- DIC and Sources.
 
Finals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quizFinals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quiz
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptx
 
EBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting BlEBUS5423 Data Analytics and Reporting Bl
EBUS5423 Data Analytics and Reporting Bl
 
Prelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quizPrelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quiz
 
Work Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sashaWork Experience for psp3 portfolio sasha
Work Experience for psp3 portfolio sasha
 
Protein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptxProtein Structure - threading Protein modelling pptx
Protein Structure - threading Protein modelling pptx
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17
 
Department of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdfDepartment of Health Compounder Question ‍Solution 2022.pdf
Department of Health Compounder Question ‍Solution 2022.pdf
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptx
 
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptxSlides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
Slides CapTechTalks Webinar March 2024 Joshua Sinai.pptx
 
A gentle introduction to Artificial Intelligence
A gentle introduction to Artificial IntelligenceA gentle introduction to Artificial Intelligence
A gentle introduction to Artificial Intelligence
 
Ultra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxUltra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptx
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdf
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptx
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 Sales
 
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptxSOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
SOLIDE WASTE in Cameroon,,,,,,,,,,,,,,,,,,,,,,,,,,,.pptx
 
Optical Fibre and It's Applications.pptx
Optical Fibre and It's Applications.pptxOptical Fibre and It's Applications.pptx
Optical Fibre and It's Applications.pptx
 

entity-relationship-diagram-chen-&-crow -model.ppt

  • 1. 1 Entity Relationship Diagram Objectives: • (b) identify the entity set, attribute, relational set and cardinality in data modelling; • (c) use E-R diagrams to model data; • (d) map the E-R diagram to a relational model: one-to- one, one-to-many and many-to-many binary relationships;
  • 2. 2 Entity-Relationship (ER) Diagram • Entity Relationship (ER) Diagram – A detailed, logical representation of the entities, associations and data elements for an organization or business • Notation uses three main constructs – Data entities – Relationships – Attributes Chen Model & Crow’s Foot Model
  • 3. Person, place, object, event or concept about which data is to be maintained named property or characteristic of an entity Association between the instances of one or more entity types Represents a set or collection of objects in the real world that share the same properties Chen Notation EntityName Verb Phrase AttributeName
  • 4. Crow’s Foot Notation EntityName Entity Attribute EntityName List of Attributes Relationship Verb phrase Acceptable
  • 5. 5 Entities • Examples of entities: – Person: EMPLOYEE, STUDENT, PATIENT – Place: STORE, WAREHOUSE – Object: MACHINE, PRODUCT, CAR – Event: SALE,REGISTRATION, RENEWAL – Concept: ACCOUNT, COURSE • Guidelines for naming and defining entity types: – An entity type name is a singular noun – An entity type should be descriptive and specific – An entity name should be concise – Event entity types should be named for the result of the event, not the activity or process of the event.
  • 6. 6 Attributes • Example of entity types and associated attributes: STUDENT: Student_ID, Student_Name, Home_Address, Phone_Number, Major • Guidelines for naming attributes: – An attribute name is a noun. – An attribute name should be unique – To make an attribute name unique and clear, each attribute name should follow a standard format – Similar attributes of different entity types should use similar but distinguishing names.
  • 7. 7 2.2.1 Identifier Attributes • Candidate key – Attribute (or combination of attributes) that uniquely identifies each instance of an entity type – Some entities may have more than one candidate key • Ex: A candidate key for EMPLOYEE is Employee_ID, a second is the combination of Employee_Name and Address. • If there is more than one candidate key, need to make a choice. • Identifier – A candidate key that has been selected as the unique identifying characteristic for an entity type
  • 8. 8 2.2.2 Referential Attributes Name IdNum DeptID Email Ali 105 LG ali@a.com Mary 106 IT mary@a.com John 107 ENG john@a.com Lim 108 IT lim@a.com Instance of Lecturer. Referential attribute: Ties the lecturer entity to another entity that is department. • Make Reference to another instance in another table
  • 10. 10 Relationships  Associations between instances of one or more entity types that is of interest  Given a name that describes its function. • relationship name is an active or a passive verb. Author Book Relationship name: writes An author writes one or more books A book can be written by one or more authors.
  • 11. 11 Degree of Relationships • Degree: number of entity types that participate in a relationship • Three cases – Unary: between two instances of one entity type – Binary: between the instances of two entity types – Ternary: among the instances of three entity types
  • 12. 12 2.4 Cardinality and Connectivity • Relationships can be classified as either • one – to – one • one – to – many • many – to –many • Cardinality : minimum and maximum number of instances of Entity B that can (or must be) associated with each instance of entity A. Connectivity
  • 13. 13 Cardinality and Connectivity Professor Class teaches A professor teaches class OR A class is taught by professor How Many?? Professor Class teaches
  • 14. 14 2.4 Cardinality and Connectivity Professor Class teaches Professor Class teaches 1 M Connectivity Connectivity (1,1) (1,1) (1,4) (1,4) Cardinality Cardinality
  • 15. 15 2.4.1 Connectivity • Chen Model – 1 to represent one. – M to represent many • Crow’s Foot many One One or many 1 M Mandatory one , means (1,1) Optional? – we’ll see after this
  • 16. 16 2.5 Binary Relationships • 1:M relationship – Relational modeling ideal – Should be the norm in any relational database design The 1: M relationship between PAINTER and PAINTING
  • 17. The Implemented 1:M relationship between PAINTER and PAINTING
  • 18. 18 2.5 Binary Relationships • 1:1 relationship – Should be rare in any relational database design – A single entity instance in one entity class is related to a single entity instance in another entity class – Could indicate that two entities actually belong in the same table
  • 19. The 1:1 Relationship Between PROFESSOR and DEPARTMENT
  • 21. 21 2.5 Binary Relationships • M:N relationships – Must be avoided because they lead to data redundancies. – Can be implemented by breaking it up to produce a set of 1:M relationships – Can avoid problems inherent to M:N relationship by creating a composite entity or bridge entity • This will be used to link the tables that were originally related in a M:N relationship • The composite entity structure includes-as foreign keys-at least the primary keys of the tables that are to be linked.
  • 22. The M:N Relationship Between STUDENT and CLASS This CANNOT be implemented as shown next….. Bowser Smithson Accounting 1 (ACCT-211) Intro to Microcomputing (CIS-220) Intro to Statistics (QM-261)
  • 23. The tables have many redundancies!! + CLASS_CODE CLASS_CODE + STU_NUM
  • 24. Changing the M:N relationship to TWO 1:M relationships
  • 25. Converting the M:N relationship into TWO 1:M relationships Foreign keys reference the primary keys in the other tables of which it has a relationship with The database designer has 2 main options to define a composite table’s primary key: either use the combination of those foreign keys or create a new primary key.
  • 26. 26 Mandatory vs. Optional Cardinalities • Specifies whether an instance must exist or can be absent in the relationship Lecturer Class handles A Lecturer may handle zero or many classes. A class is handled by one and only one Lecturer. Optional Mandatory (0,N) (1,1) Lecturer Class (0,N) (1,1) handles 1 M
  • 27. 27 How to Evaluate a Data Model? • A good data model has the following: – Accuracy and completeness – Non redundancy – Enforcement of business rules – Data Reusability – Stability and Flexibility – Communication Effectiveness – Simplicity
  • 28. 28 A Common Mistake Modeling the business processes or functions instead of the data. What data we want to keep?? We are interested in modeling the data, NOT the processes or functions that use or generate those data.
  • 29. 29 Example: Member Books Searches M N Is this part of the data requirement? Are we interested to know the books searched by the members? If answer is NO, then DO NOT include that as a relationship. Use other appropriate diagramming techniques to capture the business processes such as Data Flow Diagram. Do not mix up the use of ER Modeling with DFD.