Kendall & Kendall 2 Kendall & Kendall Systems Analysis and Design, 9e Entity Relationship Diagrams ERDs
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall
2Kendall & Kendall
Systems Analysis and Design, 9e
Entity Relationship Diagrams ERDs
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall 2-2
Entity-Relationship Model• Focus is on the Entities and their
relationships within the organizational system
• Another way to show the scope of a system
• Another way to understand the data of the system
• Will help in database creation
• Will affect programming
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall 2-3
Entity-Relationship Model• Entities and their relationships are
important because they have a direct connection with:
• Relational Databases
• See the common word “relation”
• Entity-Relationship Diagram
• Relational Database
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall 2-4
Entity-Relationship Model• Relational Databases
• A relational database usually contains many tables
• These tables connect to each other according to their relationship
• Essentially, each entity will quite probablybe a table in a relational database
• Relationships show how the entities are connected
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall 2-5
Relationships• For each relationship, you determine which
is the PRIMARY entity
• You will draw the primary entity on the top or on the left
treats
Is treated by Is/are part ofcontains
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall 2-6
Relationships• Relationship lines are labeled
• read clockwise
• Use complementary verbs that describe the same relation
treats
Is treated by
contains
Do not draw these arrows in an exercise
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall 2-7
Relationships
• Three types of relationships:
• One-to-one
• One-to-many
• Many-to-many
• This is called CARDINALITY
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall Kendall & Kendall
Relationship Notation
• Cardinality is drawn using
Crow’s Foot Notation
• One:
• If it is only one, draw two short lines
• If the one is combined with another cardinality, just use one line
• Many is indicated by a crow’s foot
• “pata de gallina”
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall Kendall & Kendall
Crow’s Foot Notation
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall Kendall & Kendall
2-10
Figure 2.8Examples of different types of relationships in E-R diagrams
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall Kendall & Kendall
Copyright © 2009 by Prentice Hall, Inc.2-11
One to One
Employee
Phone Extension
IsAssignedTo
IsListedFor
Primary Entity
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall Kendall & Kendall
Copyright © 2009 by Prentice Hall, Inc.2-12
Many to One / One to Many
Employee
Department
BelongsTo
Is composed
of
Order
Product
ContainsIs composed
of
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall Kendall & Kendall
One to Zero, One or Many
Supplier
Item
Supplies
Are Supplied
By
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall Kendall & Kendall
Copyright © 2009 by Prentice Hall, Inc.2-14
Many to Many
Flight
Passengers
HaveTravel on
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall 2-15
Entity-Relationship Example
An entity-
relationship
diagram
showing a
many-to-one
relationship
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall 2-16
Examples of Different Types of Relationships in E-R Diagrams (Figure 2.8)
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall 2-17
Attributes
• Data attributes may be added to the diagram.
Patron
Patron NamePatron addressPatron phonePatron credit card
Primary Key - will be your first field, it will be underlined- field that can uniquely identify a record
Is Patron Namea good Primary key?
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall 2-18
Attributes
Kendall & Kendall Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall 2-19
Creating Entity-Relationship Diagrams
• List the entities in the organization
• Choose key entities to narrow the scope of the problem
• Identify what the primary entity should be
• Confirm the results of the above through data gathering