0% found this document useful (0 votes)
31 views

Entity Relationship Modeling

The document discusses entity-relationship (ER) modeling concepts including: - Entities, attributes, keys, and relationships between entities in conceptual database design - The differences between conceptual, logical, and physical data models - Common components in an ER diagram like entities, attributes, domains, identifiers, and connectivity and cardinality of relationships - Additional relationship concepts such as existence dependence, relationship strength, weak entities, and relationship participation

Uploaded by

munawar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Entity Relationship Modeling

The document discusses entity-relationship (ER) modeling concepts including: - Entities, attributes, keys, and relationships between entities in conceptual database design - The differences between conceptual, logical, and physical data models - Common components in an ER diagram like entities, attributes, domains, identifiers, and connectivity and cardinality of relationships - Additional relationship concepts such as existence dependence, relationship strength, weak entities, and relationship participation

Uploaded by

munawar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Entity-Relationship Modeling

Week 3
National College of Ireland
Dublin, Ireland.

Lecturer: Dr. Muhammad Iqbal


Email: [email protected] 1
Outline
• Basic concepts associated with ER model.

• Diagrammatic technique for displaying ER model using Unified


Modeling Language (UML).

• The main characteristics of entity relationship components

• How relationships between entities are defined, refined, and


incorporated into the database design process

• How to use Entity–Relationship (ER) modeling in the database


design.

• That real-world database design often requires the reconciliation


of conflicting goals 2
A conceptual data model identifies
the highest-level relationships
between different entities.

A physical database model shows all


A logical data model describes the
table structures, including column
data in as much detail as possible,
name, column data type, column
without regard to how they will be
constraints, primary key, foreign key,
physical implemented in the database.
and relationships between tables.

3
Entities
• Entity – a person, a place, an object, an event, or a concept in the user
environment about which the organization wishes to maintain data.

• Entity type – a collection of entities that share common properties or


characteristics.

• Entity instance – A single occurrence of an entity type.

• Person: EMPLOYEE, PATIENT, CUSTOMER


• Place: STORE, WAREHOUSE
• Object: MACHINE, PRODUCT, CAR
• Event: SALE, REGISTRATION, RENEWAL
• Concept: ACCOUNT, COURSE 4
Entities
• Guidelines for naming and defining entity types:
a) An entity type name is a singular noun (usually a Proper)
b) An entity type should be descriptive and specific
c) An entity name should be concise
d) Event entity types should be named for the result of the
event, not the activity or process of the event.
Employee

5
Entity Relationship Model (ERM)
• Basis of an entity relationship diagram (ERD)
• ERD depicts the:
– Conceptual database as viewed by end user
– Database’s main components
• Entities
• Attributes
• Relationships

• Entity - Refers to the entity set and not to a


single entity occurrence 6
Attributes
• Characteristics of entities
• Required attribute: Must have a value, cannot be left empty

• Optional attribute: Does not require a value, can be left empty

• Domain - Set of possible values for a given attribute

• Identifiers: One or more attributes that uniquely identify each entity instance

7
The Attributes of the Student Entity: Chen and Crow’s Foot
Attribute Domain
• Attribute Domain
– Set of allowable values for one or more attributes.
– For example, the number of rooms associated with a
property is between 1 and 15 for each entity
occurrence.

• Simple Attribute
– Simple attributes cannot be further subdivided into smaller components.
– Examples of simple attributes include position and salary of the Staff entity.

• Composite Attribute
‒ Attribute composed of multiple components each with a separate existence.
‒ For example, the address attribute of the Branch entity with the value (163
Main St, Glasgow, G11 9QX) can be subdivided into street (163 Main St), city
8
(Glasgow), and postcode (G11 9QX) attributes.
Types of Attributes

• Single-valued Attribute
– Attribute that holds a single value for each occurrence of an entity type.
– For example, the branch number (bNo) attribute (for example B3).

• Multi-valued Attribute
– Attribute that holds multiple values for each occurrence of an entity type.
– For example, branch number B3 has telephone numbers 0141-339-2178 and
0141-339-4439.
• Derived Attribute
– Attribute that represents a value that is derivable from value of a related
attribute.
– For example, we refer to the duration attribute as a derived attribute, the value
of which is derived from the rentStart and rentFinish attributes. 9
Types of Attributes

Derived
Multivalued Calculated
an employee from date
can have more employed
than one skill and current
date
Entity with multivalued attribute (Skill) and derived
attribute (Years Employed)

Lease

Rent Rent Durat


Start Finish ion 10
Identifiers (Keys)
• Identifier (Key): An attribute (or combination of attributes) that uniquely
identifies individual instances of an entity type
• Simple versus Composite Identifier
• Candidate Identifier: An attribute that could be a key…satisfies the
requirements for being an identifier

The identifier
is boldfaced
and underlined

11
Keys
• Primary Key
– Candidate key selected to uniquely identify each
occurrence of an entity type.
– The choice of primary key for an entity is based on
considerations of attribute length and the future
certainty of uniqueness.
– For example, the company-defined staff number contains a
maximum of five characters (for example, SG14) while the
PPS_No contains a maximum of eight or nine characters (for
example, 220658AB).
– Therefore, we select staffNo as the primary key of the Staff
entity type and PPS_No is then referred to as the alternate12key.
Relationships
• Association between entities that always operate in both directions
• Participants: Entities that participate in a relationship
• Connectivity: Describes the relationship classification
• Cardinality: Expresses the minimum and maximum number of
entity occurrences associated with one occurrence of related entity

Connectivity and Cardinality in an ERD 13


Entity Relationship Diagram
• An entity-relationship diagram
(ERD) is a graphical
representation of an information
system that shows the
relationship between people,
objects, places, concepts or
events within that system.

• An ERD is a data modeling


technique that can define
business processes and can be
used as the foundation for a
relational database. 14
Existence Dependence

Existence dependence Existence independence

• Entity exists in the • Entity exists apart from


database only when it is all of its related entities
associated with another • Referred to as a strong
related entity entity or regular entity
occurrence

15
Relationship Strength
Weak (non-identifying) relationship
• Primary key of the related entity does not contain a
primary key component of the parent entity

Strong (identifying) relationships


• Primary key of the related entity contains a primary key
component of the parent entity

A Strong (Identifying) Relationship A Weak (Non-Identifying) Relationship between


16
between COURSE and CLASS COURSE and CLASS
Weak Entity
• Conditions
– Existence-dependent
– Has a primary key that is partially
or totally derived from parent entity
in the relationship
• Database designer determines
whether an entity is weak based
on business rules A Weak Entity in an ERD

A Weak Entity in a
Strong Relationship

17
Strong Entity and
Weak Entity Types

Strong Entity Weak Entity

Example of a weak identity and its identifying relationship

18
Relationship Participation
Optional participation
• One entity occurrence does not require a corresponding
entity occurrence in a particular relationship
Mandatory participation
• One entity occurrence requires a corresponding entity
occurrence in a particular relationship

19
Crow’s Foot Symbols
CLASS is Optional to COURSE

COURSE and CLASS in a Mandatory Relationship

20
Relationship Degree
• Indicates the number of entities or
participants associated with a
relationship
• Unary relationship: Association is
maintained within a single entity
– Recursive relationship: Relationship
exists between occurrences of the
same entity set

• Binary relationship: Two entities


are associated
• Ternary relationship: Three Three Types of Relationship Degree
21
entities are associated
ER Diagram: Example
A relation between school and head master

manages
School Head
1..1 1..1

A relation between Customer and Order


Each Customer places zero or more Orders

places
Customer Order
1..1 0..*

Customer ◄ one and only one ◄ is placed by ◄ Order ◄ Each 22


Example

A relation between school and head master and school


teachers

manages
School Head
1..1 1..1
1..1
hire

1..*

Teacher

23
Example

A relation between school and head master and school


teachers, and the teacher has students

manages
School Head
1..1 1..1
1..1
hire

1..*

has
Teacher Students
1..* 1..*
24
Example

Create an ER diagram for each of the following descriptions:

A company operates four departments, and each


department belongs to one company.

Operates
Company Departments
1..1 4

Cardinality
25
Example

Create an ER diagram for each of the following descriptions:


Each department in part (a) employs one or more
employees, and each employee works for one department.

Employs
Department Employee
1..1 1..*

Peter Mark

Computing Derek Kelly


Michael Hughes
26
Example
Create an ER diagram for each of the following descriptions:
Each of the employees in part (b) may or may not have
one or more dependants, and each dependant belongs to
one employee.

has
Employee Dependent
1..1 0..*

27
Example

Create an ER diagram for each of the following descriptions:


Each employee in part (c) may or may not have an
employment history.

provides Employment
Employee
0..* History
1..1

28
Represent all the ER diagrams described in (a), (b),
(c), and (d) as a single ER diagram.

Company Department

Employment
Employee
History

CrowsFoot Notation
Dependent
29
Associative (Composite) Entities
• Used to represent an M : N
relationship between two or
more entities
• Is in a 1 : M relationship with
the parent entities
– Composed of the primary key
attributes of each parent entity

• May also contain additional


Converting the M:N Relationship into Two 1:M
attributes that play no role in Relationships
connective process

A Composite Entity in an ERD


30
Developing an ER Diagram
Tiny College
• Create a detailed narrative of the
organization’s description of
operations
• Identify business rules based on the
descriptions
The First Tiny College ERD Segment
• Identify main entities and
relationships from the business rules
• Develop the initial ERD
The Second Tiny College ERD Segment
• Identify the attributes and primary
keys that adequately describe
entities
The Third Tiny College
• Revise and review ERD ERD Segment
31
Developing an ER Diagram
Tiny College

The Fourth Tiny College ERD Segment

The Fifth Tiny College ERD Segment

The Sixth Tiny College


ERD Segment
32
Developing an ER Diagram
Tiny College

The Seventh Tiny


College ERD Segment

The Eighth Tiny College


ERD Segment

33
Developing an ER Diagram
Tiny College

The Ninth Tiny College ERD Segment

Components of the ERM

34
ERD Crow’s Foot
Symbols Summary

1..1 0..1

0..1 1..*

1..* 0..*

1..1 0..* 35
Database Design Challenges:
Conflicting Goals

Database design must conform to design standards

Need for high processing speed may limit the number and
complexity of logically desirable relationships

Need for maximum information generation may lead to loss


of clean design structures and high transaction speed

36
Various Implementations of the 1:1
Recursive Relationship

37
Entity Relationship Diagram
• An entity-relationship diagram
(ERD) is a graphical
representation of an information
system that shows the
relationship between people,
objects, places, concepts or
events within that system.

• An ERD is a data modeling


technique that can define
business processes and can be
used as the foundation for a
relational database. 38
Sample E-R Diagram
SUPPLIER-PRODUCTS

39
Module Resources
Recommended Book Resources Dr. Muhammad M Iqbal*
• Thomas Connolly, Carolyn Begg 2014, Database Systems: A Practical Approach
to Design, Implementation, and Management, 6th Edition Ed., Pearson
Education [ISBN: 1292061189] [Present in our Library]
Supplementary Book Resources
• Gordon S. Linoff, Data Analysis Using SQL and Excel, Wiley [ISBN:
0470099518]
• Eric Redmond, Jim Wilson, Seven Databases in Seven Weeks, Pragmatic
Bookshelf [ISBN: 1934356921]
• Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, High Performance MySQL,
O'Reilly Media [ISBN: 1449314287]
Other Resources
• Website: http://www.thearling.com
• Website: http://www.mongodb.org
40
• Website: http://www.mysql.com

You might also like