63
Entity Relationship Diagram (ERD) عات سازمانزی اط مدلسا

Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Embed Size (px)

Citation preview

Page 1: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Entity

Relationship

Diagram (ERD)

مدلسازی اطالعات سازمان

Page 2: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

A database is a collection of data that is organized in such a manner that its contents can be readily accessed, managed and updated

An Entity Relationship model (ERM) may be used to aid the development of a

database .An ER model may be represented pictorially by ERDs

Introduction

Page 3: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

What is Conceptual Database Design?

Process of describing the data, relationships between the data, relationships between the data, and the constraints on the data.

After analysis - Gather all the essential data required and understand how the data are related

The focus is on the data, rather than on the processes. The output of the conceptual database design is a Conceptual Data Model ( +

Data Dictionary)

Introduction

Page 4: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

What is a Data Model?

A detailed model that captures overall structure of organizational data while being independent of any implementation considerations

Data Model

Page 5: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Rationale for using Data

Modelling?

Typically data modelling is carried out parallel with other requirements analysis and structuring steps during the systems analysis phase

During this phase a data model is developed for the current system

Following this, the data model supporting the scope and requirements of the proposed system is developed

Data Model

Page 6: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Entity-Relationship (ER) Modeling.

ER Modeling is a top-down approach to database design. Entity Relationship (ER) Diagram Data modelling involves examining the data objects in a system

and identifying the relationship between these objects Notation uses three main constructs

Data entities

Relationships

Attributes

Chen Model &

Crow’s Foot

Model

Entity Relationship

Page 7: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Two Styles of ERD’s

The two most popular approaches to

construct entity relationship diagrams are:

SSADM

Chen ERD

Visio provides stencils for constructing

ERD’s using these approaches

ERD

Page 8: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

ERD Symbols

SSADM Chen

Entity

Attribute

Relationship

8

Department

Staff No.

employs

Staff No

Department

Department 2

2

employs

ERD

Page 9: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

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

Page 10: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

An Entity

An entity is a thing of interest to a system about which information is kept

For example in a Hospital Administration System, some likely entities would include: Patient, Doctor, Operation, Ward

Each of these things are of interest to the system and would have data stored about them

ERD

Page 11: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Attributes

A key attribute uniquely identifies a specific occurrence of an entity

This may also be referred to as a primary key

Examples of primary keys include:

ISBN

Student Number

Staff ID

ERD

Page 12: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

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

Page 13: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Referential Attributes

Name IdNum DeptID Email

Ali 105 LG [email protected]

Mary 106 IT [email protected]

John 107 ENG [email protected]

Lim 108 IT [email protected] Instance of Lecturer.

Referential attribute: Ties the lecturer entity to

another entity that is department.

Make Reference to another instance in another table

Page 14: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

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.

Page 15: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

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

Page 16: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

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

Page 17: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Cardinality and Connectivity

Professor Class teaches

A professor teaches class OR

A class is taught by professor

How Many??

Professor Class teaches

Page 18: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

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

Page 19: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

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

Page 20: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

The Implemented 1:M relationship between PAINTER and PAINTING

Page 21: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

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

Page 22: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

The 1:1 Relationship Between PROFESSOR and DEPARTMENT

Page 23: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

The Implemented

1:1 Relationship

Between

PROFESSOR

and

DEPARTMENT

Page 24: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

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.

Page 25: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

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)

Page 26: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

The tables have many redundancies!!

+ CLASS_CODE

CLASS_CODE

+ STU_NUM

Page 27: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Changing the M:N relationship to TWO 1:M relationships

Page 28: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

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.

Page 29: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

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

Page 30: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

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

Page 31: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

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.

Page 32: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

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.

Page 33: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Choosing Entities

Example

A sale always starts with a customer

receiving an estimate. The estimate then becomes an order. An order can be for

one or more stock items. Each stock

item belongs to a certain stock category

(e.g. taps, sinks, cupboards etc.)

ERD

Page 34: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

An Attribute An attribute is an item of data held about an

entity

In computer systems an attribute is a field of

information

Example : Sales System

Entity : Customer

Attributes : Customer Name, Customer Address,

Customer Phone Number

ERD

Page 35: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

For Example

In a Sales System, customer name and

address are attributes of the entity customer.

The primary key is likely to be Customer Code or Customer ID as the unique

identifier for each customer in the system.

ERD

Page 36: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Designing a System:

Data Flow Diagramming

External entities, process, data stores

Answers question: “How will the data be used?”

Entity-Relationship Diagramming (ERDs)

Depict entities and their relationships amongst each other

Answers question: “What data will be captured in the database, and how will the data relate to each other?”

DFD Vs. ERD

Page 37: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Example : Babysitter

Service

The AITP Service Club wants to run a

babysitting service. Customers call to

request a sitter and the Club Coordinator

assigns an employee to sit for the

customer from a list of employees

available for the particular day

requested.

ERD Example

Page 38: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Babysitting System

Data is used to:

Assign employee to job

Determine availability

Data to be captured in database:

Employee data

Job data

Customer data

ERD Example

Page 39: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Entity-Relationship Model

A logical representation of the data of an

organization or business area in graphical

form

ERM

Page 40: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

ERD - Babysitter Service

Employee

Job

Customer

assigned to Related to

ERD Example

Page 41: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Babysitting System Employee

Attributes: EmpID, Name,

Address, Phone Number,

Available Hours, JobNo Job

Attributes: JobNo, JobDate,

JobTime, EmpID Customer

Attributes: CusNo, Name,

Address, Phone Number, JobNo

ERD Example

Page 42: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Entity Instance

An entity instance is a single occurrence of an

entity type.

An entity type is described just once in a data

model while many instances of that data type

may be represented by data stored in the system.

There is one EMPLOYEE entity type in most

organisations but there may be hundred or

thousands of instances of this entity type in the

company.

42

Page 43: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Choosing Entities

Example

A sale always starts with a customer

receiving an estimate.The estimate then

becomes an order. An order can be for

one or more stock items. Each stock

item belongs to a certain stock category

(e.g. taps, sinks, cupboards etc.)

ERD Example

Page 44: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

From the narrative we can deduce:

An Estimate becomes and Order

An Estimate is issued to a particular Customer

An Estimate refers to a Stock Item(s)

An Order is placed by the Customer

An Order refers to a Stock Item(s)

A Stock Item refers to a particular Stock Category

ERD Example

Page 45: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Order System: ERD

Customer

Order

Stock Item

Stock Category

Estimate

Places

Refers to

Becomes

Issued to

Refers to

Refers to

ERD Example

Page 46: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Entity Primary Key Other Attributes

Estimate Estimate Number Date

Customer Number

Stock Item Code

Order Order Number Same as Estimate

Customer Customer Number Customer Name

Customer Address

Credit Limit

Stock Item Stock Item Code Description

Number in Stock

Supplier Code

Stock Category Category Code Category Description

46

ERD Example

Page 47: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Entity Instance

An entity instance is a single occurrence of an entity type.

An entity type is described just once in a data model while many instances of that data type may be represented by data stored in the system.

There is one EMPLOYEE entity type in most organisations but there may be hundred or thousands of instances of this entity type in the company.

ERD Example

Page 48: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

ERD Relationships

A relationship is an association between two

entities that is important to the system.

We must also consider the extent to which each

entity is related to another.

ERD Example

Page 49: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

The Cardinality of a

Relationship Cardinality defines the minimum and maximum

number of occurrences of one entity for a single occurrence of the other

From the previous example we can say that:

A customer can place several orders if they wish

But an order can only be placed by one customer

ERD Example

Page 50: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Cardinality

Cardinality is bi-directional

This means that it must be defined for

both directions of the entity relationship.

ERD Example

Page 51: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

One-to-One Relationship

(1:1) A one-to-one relationship occurs where a single

occurrence of one entity relates to one occurrence

of a second entity.

Estimate Order

An estimate can only become one order and an order is derived from one estimate.

becomes

ERD Example

Page 52: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

One-to-Many

Relationship(1:N)

One-to-Many relationships occur when a

single entity instance is related to many

occurences of a second entity.

Customer Estimate

One customer can be issued with many estimates (the relationship is described as one-to-many)

is issued with

ERD Example

Page 53: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Many-to-Many Relationship

(N:M)

Many-to-many relationships occur

where many instances of an entity

relate to many instances of a

second entity

These relationships usually contain a

hidden entity which should be

extracted

Usually N:M relationships are broken

into one or more pairs of one-to-

many relationships

ERD Example

Page 54: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

N:M

Many estimates refers to many stock items

(or many stock items are referred to by

many estimates)

Estimate Stock Item Refers to

ERD Example

Page 55: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Sales ERD

Customer

Order

Stock Item

Stock Category

Estimate

Places

Refers to

Becomes

Issued to

Refers to

Refers to

ERD Example

Page 56: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Cardinality Optional Cardinality

Where the analyst considers whether an

entity occurrence at one end of the

relationship can ever be present in the

system without the presence of the

corresonding occurrence of the entity

at the other end of the relationship

Mandatory Cardinality

When the occurrence of the entity at

either end of the relationship must be

present in the system

ERD Example

Page 57: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Mandatory - Mandatory

Some relationships are mandatory and

some are optional

Doctor Patient Is responsible for

A doctor must be responsible for one or more patients and a patient must be registered with one and only one doctor

Registered with

ERD Example

Page 58: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Optional – Mandatory

Doctor PROJECT Is responsible for

A doctor may be responsible for one or more patients and a patiente must be registered with one and only one doctor

Registered with

ERD Example

Page 59: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Mandatory – Optional

A doctor must be responsible for one of

more patients and a patient may be

registered with one and only one doctor

59

Doctor Patient

Is responsible for

Registered with

Page 60: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Optional – Optional

A doctor may be responsible for one or

more patients and a patient may be

registered with one and only one doctor

Doctor Patient

Is responsible for

Registered with

ERD Example

Page 61: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Relationship Cardinality Graphic Cardinality

Exactly 1

0 or 1

1 or more

0 or many

More than 1 61

ERD Example

Page 62: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions

Note

|| denotes 1 and only

ERD Example

Page 63: Entity Relationship Diagram (ERD) - mohtaramimohtarami.com/wp-content/uploads/2014/07/ERD.pdf · Do not mix up the use of ER Modeling with DFD. Choosing Entities ... both directions