Entity-Relationship Diagram (ERD) : Yves Wautelet
Entity-Relationship Diagram (ERD) : Yves Wautelet
Entity-Relationship Diagram (ERD) : Yves Wautelet
Yves Wautelet
Content
• What is an Entity Relationship Diagram (ERD)?
• What are Entities in an ERD?
• What are Attributes in an ERD?
• What are Relationships in an ERD?
• How to build an ERD
Database Design
• Conceptual
Before we look
design
at how to create and use a database we’ll look at how to design
oneBuild a model independent of the choice of DBMS
o
• Logical
Need todesign
consider
o What tables,
Create keys, and
the database constraints
in a given DBMSare needed?
• o What is the database going to be used for?
Physical design
o How the database is stored in hardware
Entity Relationship Diagram
• The purpose of an ERD is to capture the richest possible understanding of the
meaning of data necessary for an information system or organization.
• An Entity has its own identity that distinguishes it from other entities.
o Examples:
• Person: PROFESSOR, STUDENT
• Place: STORE, UNIVERSITY
• Object: MACHINE, BUILDING
• Event: SALE, REGISTRATION
• Concept: ACCOUNT, COURSE
Diagramming Entities
• In an E/R Diagram, an entity is usually drawn as a box with rounded corners
• The box is labelled with the name of the class of objects represented
ID
by that
Lecturer
entity
Name Course
Tutors Student
Module Studies
Attributes
• Attributes are facts, aspects, properties, or details about an entity
o Students have IDs, names, courses, addresses, …
o Modules have codes, titles, credit weights, levels, …
• Attributes have
o A name
o An associated entity
o Domains of possible values
o Values from the domain for each instance of the entity they are belong to
Diagramming Attributes
• In an E/R Diagram attributes may be drawn as ovals
• Each attribute is linked to its entity by a line ID
Lecturer
• The name of the attribute is written in the oval
Name Course
Tutors Student
Module Studies
Relationships
• Relationships are an association between two or more entities
o Each Student takes several Modules
o Each Module is taught by a Lecturer
o Each Employee works for a single Department
• Relationships have
o A name
o A set of entities that participate in them
o A degree - the number of entities that participate (most have degree 2)
o A cardinality
Cardinality Ratios
• One
Eachtoentity
one in(1:1)
a relationship can participate in zero, one, or more than one
o Each lecturer
instances has arelationship
of that unique office
•• One to many
This leads (1:M) types of relationships
to different
o A lecturer may tutor many students, but each student has just one tutor
• Many to many (M:M)
o Each student takes several modules, and each module is taken by several students
Basic Cardinality Type
• 1-to-1 relationship
• 1-to-M relationship
• M-to-M relationship
Cardinality con’t
Diagramming Relationships
• Relationships are links between two entities
Lecturer ID
• The name is given in a diamond box
• The ends of the link show cardinality Name Course
Tutors Student
Module Studies
Department
Student
Example - E/R Diagram
Offers Department
Student
Example - E/R Diagram
Offers Department
Student
Example - E/R Diagram
Offers Department
Enrols In Student
Example - E/R Diagram
Offers Department
Takes
Enrols In Student
Example - E/R Diagram
Offers Department
Takes
Enrols In Student
Example - E/R Diagram
Takes
Enrols In Student
Example - E/R Diagram
Takes
Takes
Price
Description Product
Street address
Price
Description Product
c z
a x
b AB y
c z