ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives Describe data relationships ...

22
ERD diagram ERD diagram - Mr. Ahmad Al-Ghoul - Mr. Ahmad Al-Ghoul Data Design Data Design

Transcript of ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives Describe data relationships ...

Page 1: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

ERD diagramERD diagram

- Mr. Ahmad Al-Ghoul- Mr. Ahmad Al-Ghoul

Data DesignData Design

Page 2: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

22

learning Objectiveslearning Objectives

Describe data Describe data relationshipsrelationships

Define cardinality, and Define cardinality, and use cardinality notationuse cardinality notation

Draw an entity-Draw an entity-relationship diagramrelationship diagram

Page 3: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

33

Page 4: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

44

Page 5: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

55

Page 6: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

66

Entity-Relationship DiagramsEntity-Relationship Diagrams What Is an ERD?What Is an ERD?

A picture showing the information A picture showing the information created, stored, and used by a business created, stored, and used by a business system. system.

ERD is network model that describes ERD is network model that describes stored data of a system at a high level stored data of a system at a high level of abstraction.of abstraction.

Entities generally represent similar kinds Entities generally represent similar kinds of informationof information

Lines drawn between entities show Lines drawn between entities show relationships among the datarelationships among the data

High level business rules are also shownHigh level business rules are also shown

Page 7: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

77

Entity-Relationship Entity-Relationship DiagramsDiagrams

Representing entitiesRepresenting entities we represent an entity by a named we represent an entity by a named

rectanglerectangle use a singular noun, or adjective + nounuse a singular noun, or adjective + noun refer to one instance in namingrefer to one instance in naming

PART-TIMEEMPLOYEE

CUSTOMER

Page 8: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

88

Entity-Relationship Entity-Relationship DiagramsDiagrams

Entity types and instancesEntity types and instances an entity type is a classification of entity an entity type is a classification of entity

instancesinstances Example AhmadExample Ahmad

AmalAmal

OsamaOsama

SUPPLIER

Page 9: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

99

Entity-Relationship DiagramsEntity-Relationship Diagrams RelationshipRelationship

is an association between two entitiesis an association between two entities

we may wish to store information about the associationwe may wish to store information about the association Relationships should have active verb namesRelationships should have active verb names

often recognised by a verb or often recognised by a verb or "entity + verb + entity" "entity + verb + entity"

eg CUSTOMER places ORDEReg CUSTOMER places ORDER

relationships capture the "business rules" of the systemrelationships capture the "business rules" of the system The first entity in the relationship is the The first entity in the relationship is the parent parent entity; entity;

the second entity in the relationship is thethe second entity in the relationship is the child child entityentity Relationships go in both directionsRelationships go in both directions

Page 10: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

1010

Entity-Relationship Entity-Relationship DiagramsDiagrams

A Relationship Type is a relevant business association A Relationship Type is a relevant business association between two Entity Types.between two Entity Types.

A Relationship is an occurrence of a relationship type.A Relationship is an occurrence of a relationship type.

MIS FinanceMarketing

Ahmad Al ghoulOsama MlkawiYosef Aliemploys

employsemploys

DEPT EMPLOYEEemploysemploys

Page 11: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

1111

Entity-Relationship Entity-Relationship DiagramsDiagrams

Types of Types of RelationshipsRelationships Three types of Three types of

relationships can relationships can exist between exist between entitiesentities

One-to-one relationOne-to-one relationship ship ((1:11:1): One instance ): One instance in an entity (parent) in an entity (parent) refers to one and refers to one and only one instance in only one instance in the related entity the related entity (child)(child)

Page 12: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

1212

Entity-Relationship Entity-Relationship DiagramsDiagrams

Types of Types of RelationshipsRelationships One-to-many One-to-many

relationship relationship (1:M): One (1:M): One instance in an instance in an entity (parent) entity (parent) refers to one or refers to one or more instances more instances in the related in the related entity (child)entity (child)

Page 13: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

1313

Entity-Relationship DiagramsEntity-Relationship Diagrams

Types of Types of RelationshipsRelationships Many-to-many Many-to-many

relationship (M:N): relationship (M:N): exists when one exists when one instance of the first instance of the first entity (parent) can entity (parent) can relate to many relate to many instances of the instances of the second entity second entity (child), and one (child), and one instance of the instance of the second entity can second entity can relate to many relate to many instances of the first instances of the first entity. entity.

Page 14: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

1414

Entity-Relationship Entity-Relationship DiagramsDiagrams Types of RelationshipsTypes of Relationships

Many-to-many relationship (M:N):Many-to-many relationship (M:N): this relationship can not this relationship can not

represent physically so we represent physically so we solve this problem by dividing it solve this problem by dividing it to two (1:M) relationships.to two (1:M) relationships.

The relationship between The relationship between STUDENT and CLASS is many-STUDENT and CLASS is many-to-many, one student can take to-many, one student can take many classes, and one class many classes, and one class can have many students.can have many students.

To solve the problem of this To solve the problem of this relationship note that the event relationship note that the event or transaction that links the two or transaction that links the two entities is actually a third entity, entities is actually a third entity, called Associative entity that called Associative entity that has its own characteristics.has its own characteristics.

In the next section In the next section (normalization) you will see how (normalization) you will see how we will solve this problem.we will solve this problem.

Associative Entity

Page 15: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

1515

Entity-Relationship Entity-Relationship DiagramsDiagrams

Cardinalities in relationshipsCardinalities in relationships The cardinality of a relationship is the The cardinality of a relationship is the

number of instances of one entity type number of instances of one entity type that may be associated with each that may be associated with each instance of the other entity type.instance of the other entity type.

An analyst can model this interaction by An analyst can model this interaction by adding cardinality notation, which uses adding cardinality notation, which uses special symbols to represent the special symbols to represent the relationship.relationship.

Page 16: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

1616

Entity-Relationship Entity-Relationship DiagramsDiagrams

CardinalityCardinality Cardinality notationCardinality notation: : Notation that shows Notation that shows

relationships between entities. relationships between entities. Crow’s foot notation: A type of cardinality Crow’s foot notation: A type of cardinality

notation. It is called crow's foot notation notation. It is called crow's foot notation because of the shapes, which include circles, because of the shapes, which include circles, bars, and symbols, that indicate various bars, and symbols, that indicate various possibilities. A single bar indicates one, a possibilities. A single bar indicates one, a double bar indicates one and only one, a circle double bar indicates one and only one, a circle indicates zero, and a crow's foot indicates indicates zero, and a crow's foot indicates many. many.

Page 17: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

1717

Entity-Relationship Entity-Relationship DiagramsDiagrams

Crow's foot notation is a common method of indicating cardinality. The four examples show how you can use various symbols to describe the relationships between entities.

Page 18: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

1818

Entity-Relationship DiagramsEntity-Relationship Diagrams

In the first example of cardinality notation, one and only one CUSTOMER can place anywhere from zero to many of the ORDER entity. In the second example, one and only one ORDER can include one ITEM ORDERED or many. In the third example, one and only one EMPLOYEE can have one SPOUSE or none. In the fourth example, one EMPLOYEE, or many employees, or none, can be assigned to one PROJECT, or many projects, or none.

Page 19: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

1919

Entity-Relationship Entity-Relationship DiagramsDiagrams

The entity-relationship diagram may be The entity-relationship diagram may be used to determine record keysused to determine record keys When the relationship is one-to-many, the When the relationship is one-to-many, the

primary key of the file at the one end of the primary key of the file at the one end of the relationship should be contained as a foreign relationship should be contained as a foreign key on the file at the many end of the key on the file at the many end of the relationshiprelationship

A many-to-many relationship should be divided A many-to-many relationship should be divided into two one-to-many relationships with an into two one-to-many relationships with an associative entity in the middleassociative entity in the middle

Page 20: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

2020

Sequence SummarySequence Summary An entity-relationship diagram (ERD) is a An entity-relationship diagram (ERD) is a

graphic representation of all system entities and graphic representation of all system entities and the relationships among them the relationships among them

The ERD is based on entities and data stores in The ERD is based on entities and data stores in DFDs prepared during the systems analysis DFDs prepared during the systems analysis phasephase

The three basic relationships represented in an The three basic relationships represented in an ERD are one-to-one (1:1), one-to-many (1:M), ERD are one-to-one (1:1), one-to-many (1:M), and many-to-many (M:N)and many-to-many (M:N)

In a M:N relationship, the two entities are linked In a M:N relationship, the two entities are linked by an associative entityby an associative entity

The relationship between two entities also is The relationship between two entities also is referred to as cardinalityreferred to as cardinality

A common form if cardinality notation is called A common form if cardinality notation is called crow’s foot notation, which uses various crow’s foot notation, which uses various symbols to describe the characteristics of the symbols to describe the characteristics of the relationshiprelationship

Page 21: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

2121

Sequence SummarySequence Summary

In this Sequence we haveIn this Sequence we have Defined entity relationship diagram Defined entity relationship diagram

(ERD)(ERD) Defined and Defined and distinguished between distinguished between

entity type and entity instanceentity type and entity instance Defined and distinguished between Defined and distinguished between

relationship and relationship typerelationship and relationship type Explained types of relationshipsExplained types of relationships Defined cardinality, and used Defined cardinality, and used

cardinality notationcardinality notation

Page 22: ERD diagram - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Describe data relationships  Define cardinality, and use cardinality notation

2222

ReferenceReference

[1] System Analysis and Design, Sixth [1] System Analysis and Design, Sixth EditionEdition

Authors: Gary B. Shelly, Thomas J. Authors: Gary B. Shelly, Thomas J. Cashman and Harry J. Rosenblatt Cashman and Harry J. Rosenblatt

Publisher: SHELLY CASHMAN Publisher: SHELLY CASHMAN SEWIES.SEWIES.