SlideShare une entreprise Scribd logo
1  sur  25
Entity Relationship Diagram
A complete guide to design ER Diagrams
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 1
Contents / Agenda
• Definition
• Basic Components
• ERD Representations
• Chen’s Notation Symbols
• Crow’s foot Notation Symbols
• UML Notation Symbols
• Type of Entities
• Types of Attributes
• How to solve multivalued attributes
• Types of Relationships
• Implementation of 1:1
• Implementation of 1:M
• Implementation of M:M
• Connectivity and Cardinalities
• Summary
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 2
Definition
• The Relational Database Model (ERM-database containing tables)
forms on the basis of an ERD. The ERD represents the conceptual
database as viewed by the end user.
• ERDs depict the database’s main components: entities, attributes, and
relationships. Because an entity represents a real-world object, the
words entity and object are often used interchangeably. Thus, the
entities (objects) of the Tiny College database design (mostly discussed
in these slides) include students, classes, teachers and classrooms.
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 3
Basic Components of ERD
• Entities:
• An entity is an object of interest to the end user. At the ER modeling level, an entity actually refers to the entity set and
not to a single entity occurrence. In other words, the word entity in the ERM corresponds to a table—not to a row—in
the relational environment. The ERM refers to a table row as an entity instance or entity occurrence.
• In both the Chen and Crow’s Foot notations, an entity is represented by a rectangle containing the entity’s name. The
entity name, a noun, is usually written in all capital letters.
• Attributes:
• Attributes are characteristics of entities. For example, the STUDENT entity includes, among many others, the attributes
STU_LNAME, STU_FNAME, and STU_INITIAL. In the original Chen notation, attributes are represented by ovals and are
connected to the entity rectangle with a line. Each oval contains the name of the attribute it represents.
• In the Crow’s Foot notation, the attributes are written in the attribute box below the entity rectangle. Because the Chen
representation is rather space-consuming, software vendors have adopted the Crow’s Foot style attribute display.
• Relationships:
• A relationship is an association between entities. The entities that participate in a relationship are also known as
participants, and each relationship is identified by a name that describes the relationship. The relationship name is an
active or passive verb; for example, a STUDENT takes a CLASS, a PROFESSOR teaches a CLASS and an AIRCRAFT is flown
by a CREW.
• Relationships between entities always operate in both directions. That is, to define the relationship between the entities
named CUSTOMER and INVOICE, you would specify that:
1. A CUSTOMER may generate many INVOICEs.
2. Each INVOICE is generated by one CUSTOMER.
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 4
ERD Representations
• There are three main notations to represent and ERD
1. The Chen notation favors conceptual modeling.
2. The Crow’s Foot notation favors a more implementation-oriented approach.
3. The UML notation can be used for both conceptual and implementation
modeling.
• Because of its implementation emphasis, the Crow’s Foot notation can
represent only what could be implemented.
• We will also be using a new Short Hand notation that is easy to
understand and takes less place.
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 5
Chen Notation Symbols
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 6
Crow’s Foot Notation Symbols
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 7
UML Notation Symbols
Primary Keys are followed by [PK]
Foreign Keys are followed by [FK]
Relationships:
Cardinality 1 for ‘One’.
Cardinality * for ‘Many’.
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 8
Advantages and Usage
• Advantages:
1. ERD tells us that how many tables you need and what would be the
relationship between them (you also have to do Normalization to know
finally how many tables would be in your database but still first step is ERD).
2. ERD is simple and understandable representation of a database. It helps a lot
to understand the whole database.
• Usage:
1. An ERD leads to ERM, means when ever you need to build a database with
tables, firstly, you need to create an ERD.
2. Crow’s foot notation is used most of all because its easy to understand in
implementation point of view.
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 9
Types of Entities
• Existence Dependent
An entity is said to be existence-dependent if it can exist in the database
only when it is associated with another related entity occurrence. In
implementation terms, an entity is existence-dependent if it has a
mandatory foreign key—that is, a foreign key attribute that cannot be
null.
• Existence Independent.
If an entity can exist apart from one or more related entities, it is said to
be existence-independent (Sometimes designers refer to such an entity
as a strong or regular entity). Here foreign key attribute can be null.
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 10
Types of Attributes (1)
• Required
A required attribute is an attribute that must have a value; in other words, it cannot be left
empty.
• Optional
An optional attribute is an attribute that does not require a value; therefore, it can be left empty.
• Domains
Attributes have a domain, a domain is the set of possible values for a given attribute. For
example, the domain for the grade point average (GPA) attribute is written (0,4) because the
lowest possible GPA value is 0 and the highest possible value is 4. The domain for the gender
attribute consists of only two possibilities: M or F (or some other equivalent code).
• Identifiers
The ERM uses identifiers, that is, one or more attributes that uniquely identify each entity
instance. In the relational model, such identifiers are mapped to primary keys (PKs) in tables.
There are Simple(Primary Key) and Composite (Composite Key) identifiers.
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 11
Types of Attributes (2)
• Composite
A composite attribute, not to be confused with a composite key, is an attribute that can be further subdivided to yield
additional attributes. For example, the attribute ADDRESS can be subdivided into street, city, state, and zip code.
• Simple
A simple attribute is an attribute that cannot be subdivided. For example, age, sex, and marital status would be classified
as simple attributes.
• Single-Valued
A single-valued attribute is an attribute that can have only a single value. For example, a person can have only one Social
Security number, and a manufactured part can have only one serial number. Keep in mind that a single-valued attribute is
not necessarily a simple attribute. For instance, a part’s serial number, such as SE-08-02-189935, is single-valued, but it is
a composite attribute because it can be subdivided into the region in which the part was produced (SE), the plant within
that region (08), the shift within the plant (02), and the part number (189935).
• Multi-Valued
Multivalued attributes are attributes that can have many values. For instance, a person may have several college degrees,
and a household may have several different phones, each with its own number. Similarly, a car’s color may be subdivided
into many colors (that is, colors for the roof, body, and trim).
• Derived
A derived attribute is an attribute whose value is calculated (derived) from other attributes. The derived attribute need
not be physically stored within the database; instead, it can be derived by using an algorithm. For example, an
employee’s age, EMP_AGE, may be found by computing the integer value of the difference between the current date and
the EMP_DOB.
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 12
How to Solve Multi-Valued attributes (1)
• Although the conceptual model can handle M:N relationships and
multivalued attributes, you should not implement them in the RDBMS.
Because in the relational table, each column/row intersection represents a
single data value. So if multivalued attributes exist, the designer must
decide on one of two possible courses of action:
1. Within the original entity, create several new attributes, one for each of the original
multivalued attribute’s components. For example, the CAR entity’s attribute
CAR_COLOR can be split to create the new attributes CAR_TOPCOLOR,
CAR_BODYCOLOR, and CAR_TRIMCOLOR, which are then assigned to the CAR entity.
(Not good).
2. Create a new entity composed of the original multivalued attribute’s components.
The new (independent) CAR_COLOR entity is then related to the original CAR entity
in a 1:M relationship. Note that such a change allows the designer to define color
for different sections of the car like top, body, interior etc. (Best solution).
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 13
How to Solve Multi-Valued attributes (2)
Entity CAR contains a multivalued
attribute CAR_COLOR.
Solution 1: (Not good)
Solution to Multi-Valued attribute
by adding new attributes to CAR
entity.
Solution 2: (Best)
Solution to Multi-Valued attribute
by adding new entity with 1:M
relation to CAR entity.
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 14
Relationships
• Ways of Classifying Relationships Types
A relationship type can be classified by the number of entity types involved, and by the degree of the
relationship type.
Following is a brief picture showing all types of relationships.
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 15
Types of Relationships (1)
• One-to-One
• When both participants can have only one instance of each other. (less used but stable).
• For Example, HUSBAND can have only one WIFE and WIFE can have only one HUSBAND. This
is 1:1 relationship between HUSBAND and WIFE participants.
• One-to-Many
• When one participant can have multiple instances of other participants but other participant
can have only one instance of first participants. (mostly used and stable).
• For Example, CUSTOMER may generate many ORDERs but each ORDER is generated by one
CUSTOMER. This is 1:M relation between CUSTOMER and ORDER.
• Many-to-Many
• When both participants can have multiple instances of each other. (not practice).
• For Example, STUDENT can be enrolled in many SUBJECTs and one SUBJECT can be chosen
by many STUDENTs. This is M:M relation between STUDENT and SUBJECT.
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 16
Types of Relationships (2)
• Weak relationship
Also known as a non-identifying relationship, exists if the PK of the related entity does not
contain a PK component of the parent entity. By default, relationships are established by having
the PK of the parent entity appear as an FK on the related entity (implemented in right picture).
• Strong relationship
Also known as an identifying relationship, exists when the PK of the related entity contains a PK
component of the parent entity (implemented in left picture).
• Recursive relationship
• A recursive relationship is one in which a relationship can exist between occurrences of the
same entity set (Naturally, such a condition is found within a unary relationship).
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 17
Relationships (1:1) – Implementation (1)
• An example of a one-one relationship type is a person and his or her birth
certificate. We assume that everyone has one and that a certificate registers the
birth of one person only.
• Where there is a one-one relationship type we have the option of merging the
two entity types. The birth certificate attributes may be considered as attributes
of the person and placed in the person entity type. The birth certificate entity
type would then be removed.
• There are two reasons for not merging them:
1. The majority of processing involving PERSON records might not involve any or many of
the BIRTH_CERTIFICATE attributes. The BIRTH_CERTIFICATE attributes might only be
subject to very specific processes which are rarely executed.
2. the BIRTH_CERTIFICATE entity type has relationship types to other entity types that the
PERSON entity type does not have. The two entity types have different relationship types
to other entity types.
• Merging is not very harmful practically. so, its just a matter of choice which
implementation you want.
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 18
Relationships (1:1) – Implementation (2)
• Following is implementations for 1:1 relationship.
One table has PK and other table must have same PK as well as FK.
Department Table has Department_ID as PK.
And Manager Table must have Department_ID as
PK as well as FK (You can change the name of
column but it should have same data).
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 19
Relationships (1:M) - Implementation
• The common column is DEPARTMENT_ID (which is the primary key in
the DEPARTMENT table) should be as a foreign key in the EMPLOYEE
table. One individual DEPARTMENT_ID can relate to many rows in the
EMPLOYEE table.
Business Rule for this is:
“one department can relate to one or
many employees (or even no
employees) and that an employee is
associated with only one department
(or, in some cases, no department).”
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 20
Relationships (M:N) – Implementation (1)
• Consider the EMPLOYEE and PROJECT tables. The business rule is as follows:
One employee can be assigned to multiple projects, and one project can be
supported by multiple employees. Therefore, it is necessary to create an
M:M relationship to link these two tables.
• In the relational database we don’t implement the M:N relation by just
giving FKs to each other and the reason is we don’t want two sided links
(circles). So, we create a new entity called Bridge Entity and its PK is a
composite key made up with PKs of both tables. It may or may not have any
other attributes but composite key is must.
• After doing this, there becomes two 1:M relations.
1. One between Bridge and EMPLOYEE table (1:M).
2. One between Bridge and PROJECT table (1:M).
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 21
Relationships (M:N) – Implementation (2)
In this example we made Bridge Table
under name EMPLOYEE_PROJECT
containing PKs of both above tables. It
has one more attribute for some extra
information.
Now, it becomes like this and we have
three tables now.
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 22
Removing Ternary and Hire order relations
• It is advantageous (but not necessary) to remove ternary and higher order relationship types. One
reason is that it might be considered more `natural' to think of entity types having attributes than
relationship types having them. It is in fact always possible to remove these high-order relationship
types and replace them with an entity type. A ternary relationship type is then replaced by an
entity type and three binary relationship types linking it to the entity types which were originally
linked by the ternary. A quaternary relationship type would be replaced by an entity type and four
relationship types and so on.
Ternary Relation Ternary Relation Solved into binary relations
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 23
Connectivity and Cardinalities
• Connectivity:
The term connectivity is used to describe the relationship classification. Just to show the relation
existence and type of relation between entities.
• Cardinalities:
Cardinality expresses the minimum and maximum number of entity occurrences associated with
one occurrence of the related entity. In the ERD, cardinality is indicated by placing the
appropriate numbers beside the entities, using the format (min , max).
1. Cardinality / mandatory:
maximum cardinality.
2. Modality / optional:
minimum cardinality or optionality.
Picture says, one PROFESSOR can teach one (min 1)
or more (max 4) CLASSes but each single (min 1)
CLASS can be taught by one (max 1) PROFESSOR at
time.
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 24
Summary
• Following are main steps to create an ERD
1. Decide what are the entitles in your database.
2. Decide attributes for each entity.
3. Describe relationships between entities.
1. If there is any M:N relation, solve it into 1:M relationships.
• Note: ERD will not output a complete blue print to your database until
you do its Normalization. But, ERD + Normalization will give you
complete set of tables, attributes and relationships you need in your
database.
19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 25

Contenu connexe

Tendances

Enhanced E-R diagram
Enhanced E-R diagramEnhanced E-R diagram
Enhanced E-R diagram
Mayank Jain
 
Data modeling using the entity relationship model
Data modeling using the entity relationship modelData modeling using the entity relationship model
Data modeling using the entity relationship model
Jafar Nesargi
 
Entity relationship diagram (erd)
Entity relationship diagram (erd)Entity relationship diagram (erd)
Entity relationship diagram (erd)
tameemyousaf
 

Tendances (20)

The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database Model
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 
Entity Relationship Modelling
Entity Relationship ModellingEntity Relationship Modelling
Entity Relationship Modelling
 
Enhanced Entity-Relationship (EER) Modeling
Enhanced Entity-Relationship (EER) ModelingEnhanced Entity-Relationship (EER) Modeling
Enhanced Entity-Relationship (EER) Modeling
 
Erd practice exercises
Erd practice exercisesErd practice exercises
Erd practice exercises
 
ER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMSER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMS
 
Enhanced E-R diagram
Enhanced E-R diagramEnhanced E-R diagram
Enhanced E-R diagram
 
Data modeling using the entity relationship model
Data modeling using the entity relationship modelData modeling using the entity relationship model
Data modeling using the entity relationship model
 
Entity relationship diagram (erd)
Entity relationship diagram (erd)Entity relationship diagram (erd)
Entity relationship diagram (erd)
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
 
E r model
E r modelE r model
E r model
 
Er diagram
Er diagramEr diagram
Er diagram
 
Entity (types, attibute types)
Entity (types, attibute types)Entity (types, attibute types)
Entity (types, attibute types)
 
ER diagram powerpoint
ER diagram powerpointER diagram powerpoint
ER diagram powerpoint
 
Entity Relationship Diagrams
Entity Relationship DiagramsEntity Relationship Diagrams
Entity Relationship Diagrams
 
DBMS PPT
DBMS PPTDBMS PPT
DBMS PPT
 
Elmasri Navathe DBMS Unit-1 ppt
Elmasri Navathe DBMS Unit-1 pptElmasri Navathe DBMS Unit-1 ppt
Elmasri Navathe DBMS Unit-1 ppt
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 
Data Modeling PPT
Data Modeling PPTData Modeling PPT
Data Modeling PPT
 
EER modeling
EER modelingEER modeling
EER modeling
 

En vedette

Entity relationship diagram (erd)
Entity relationship diagram (erd)Entity relationship diagram (erd)
Entity relationship diagram (erd)
tameemyousaf
 
RDBMS ERD Examples
RDBMS ERD ExamplesRDBMS ERD Examples
RDBMS ERD Examples
Sarmad Ali
 

En vedette (10)

Entity relationship diagram (erd)
Entity relationship diagram (erd)Entity relationship diagram (erd)
Entity relationship diagram (erd)
 
Osi , tcp/ip protocol and Addressing
Osi , tcp/ip protocol and Addressing Osi , tcp/ip protocol and Addressing
Osi , tcp/ip protocol and Addressing
 
Informational Referential Integrity Constraints Support in Apache Spark with ...
Informational Referential Integrity Constraints Support in Apache Spark with ...Informational Referential Integrity Constraints Support in Apache Spark with ...
Informational Referential Integrity Constraints Support in Apache Spark with ...
 
Oracle Forms: Messages
Oracle Forms: MessagesOracle Forms: Messages
Oracle Forms: Messages
 
Erd optionality
Erd optionalityErd optionality
Erd optionality
 
SQL Stored Procedures For My Library Project
SQL Stored Procedures For My Library ProjectSQL Stored Procedures For My Library Project
SQL Stored Procedures For My Library Project
 
RDBMS ERD Examples
RDBMS ERD ExamplesRDBMS ERD Examples
RDBMS ERD Examples
 
Erd
ErdErd
Erd
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Erd cardinality
Erd cardinalityErd cardinality
Erd cardinality
 

Similaire à Database - Entity Relationship Diagram (ERD)

dbms (database management system )1.pptx
dbms (database management system )1.pptxdbms (database management system )1.pptx
dbms (database management system )1.pptx
227r1a0519
 
entity-relationship-diagram-chen-&-crow -model.ppt
entity-relationship-diagram-chen-&-crow -model.pptentity-relationship-diagram-chen-&-crow -model.ppt
entity-relationship-diagram-chen-&-crow -model.ppt
IRWANBINISMAILKPMGur1
 

Similaire à Database - Entity Relationship Diagram (ERD) (20)

3. Chapter Three.pdf
3. Chapter Three.pdf3. Chapter Three.pdf
3. Chapter Three.pdf
 
ER Digramms by Harshal wagh
ER Digramms by Harshal waghER Digramms by Harshal wagh
ER Digramms by Harshal wagh
 
database1
database1database1
database1
 
Introduction to Database Management Systems
Introduction to Database Management Systems Introduction to Database Management Systems
Introduction to Database Management Systems
 
Chapter-3 Data Modeling using ER Model
Chapter-3 Data Modeling using ER ModelChapter-3 Data Modeling using ER Model
Chapter-3 Data Modeling using ER Model
 
Chapter-3 Data Modeling Using the Entity-Relationship Model
Chapter-3  Data Modeling Using the Entity-Relationship ModelChapter-3  Data Modeling Using the Entity-Relationship Model
Chapter-3 Data Modeling Using the Entity-Relationship Model
 
ER modeling
ER modelingER modeling
ER modeling
 
Database part3-
Database part3-Database part3-
Database part3-
 
DBMS CS 4-5
DBMS CS 4-5DBMS CS 4-5
DBMS CS 4-5
 
Unit 2 DBMS
Unit 2 DBMSUnit 2 DBMS
Unit 2 DBMS
 
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...
Fundamentals of database system  - Data Modeling Using the Entity-Relationshi...Fundamentals of database system  - Data Modeling Using the Entity-Relationshi...
Fundamentals of database system - Data Modeling Using the Entity-Relationshi...
 
Computer sec2-1st term
Computer sec2-1st termComputer sec2-1st term
Computer sec2-1st term
 
Advance database system(part 4)
Advance database system(part 4)Advance database system(part 4)
Advance database system(part 4)
 
ER diagram slides for datanase stujdy-1.pdf
ER diagram slides for datanase stujdy-1.pdfER diagram slides for datanase stujdy-1.pdf
ER diagram slides for datanase stujdy-1.pdf
 
Unit 2-Data Modeling.pdf
Unit 2-Data Modeling.pdfUnit 2-Data Modeling.pdf
Unit 2-Data Modeling.pdf
 
dbms (database management system )1.pptx
dbms (database management system )1.pptxdbms (database management system )1.pptx
dbms (database management system )1.pptx
 
er-models.pptx
er-models.pptxer-models.pptx
er-models.pptx
 
Introduction of Database Design and Development
Introduction of Database Design and DevelopmentIntroduction of Database Design and Development
Introduction of Database Design and Development
 
ER-Diagram.pptx
ER-Diagram.pptxER-Diagram.pptx
ER-Diagram.pptx
 
entity-relationship-diagram-chen-&-crow -model.ppt
entity-relationship-diagram-chen-&-crow -model.pptentity-relationship-diagram-chen-&-crow -model.ppt
entity-relationship-diagram-chen-&-crow -model.ppt
 

Plus de Mudasir Qazi

Plus de Mudasir Qazi (14)

Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory Pattern
 
Database - SQL Joins
Database - SQL JoinsDatabase - SQL Joins
Database - SQL Joins
 
Database - Normalization
Database - NormalizationDatabase - Normalization
Database - Normalization
 
OOP - Understanding association, aggregation, composition and dependency
OOP - Understanding association, aggregation, composition and dependencyOOP - Understanding association, aggregation, composition and dependency
OOP - Understanding association, aggregation, composition and dependency
 
OOP - Polymorphism
OOP - PolymorphismOOP - Polymorphism
OOP - Polymorphism
 
OOP - Java is pass-by-value
OOP - Java is pass-by-valueOOP - Java is pass-by-value
OOP - Java is pass-by-value
 
OOP - Benefits and advantages of OOP
OOP - Benefits and advantages of OOPOOP - Benefits and advantages of OOP
OOP - Benefits and advantages of OOP
 
Design Pattern - Singleton Pattern
Design Pattern - Singleton PatternDesign Pattern - Singleton Pattern
Design Pattern - Singleton Pattern
 
Design Pattern - Observer Pattern
Design Pattern - Observer PatternDesign Pattern - Observer Pattern
Design Pattern - Observer Pattern
 
Design Pattern - MVC, MVP and MVVM
Design Pattern - MVC, MVP and MVVMDesign Pattern - MVC, MVP and MVVM
Design Pattern - MVC, MVP and MVVM
 
Design Pattern - Introduction
Design Pattern - IntroductionDesign Pattern - Introduction
Design Pattern - Introduction
 
Design Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternDesign Pattern - Factory Method Pattern
Design Pattern - Factory Method Pattern
 
Design pattern - Facade Pattern
Design pattern - Facade PatternDesign pattern - Facade Pattern
Design pattern - Facade Pattern
 
Design Pattern - Chain of Responsibility
Design Pattern - Chain of ResponsibilityDesign Pattern - Chain of Responsibility
Design Pattern - Chain of Responsibility
 

Dernier

Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Dernier (20)

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 

Database - Entity Relationship Diagram (ERD)

  • 1. Entity Relationship Diagram A complete guide to design ER Diagrams 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 1
  • 2. Contents / Agenda • Definition • Basic Components • ERD Representations • Chen’s Notation Symbols • Crow’s foot Notation Symbols • UML Notation Symbols • Type of Entities • Types of Attributes • How to solve multivalued attributes • Types of Relationships • Implementation of 1:1 • Implementation of 1:M • Implementation of M:M • Connectivity and Cardinalities • Summary 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 2
  • 3. Definition • The Relational Database Model (ERM-database containing tables) forms on the basis of an ERD. The ERD represents the conceptual database as viewed by the end user. • ERDs depict the database’s main components: entities, attributes, and relationships. Because an entity represents a real-world object, the words entity and object are often used interchangeably. Thus, the entities (objects) of the Tiny College database design (mostly discussed in these slides) include students, classes, teachers and classrooms. 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 3
  • 4. Basic Components of ERD • Entities: • An entity is an object of interest to the end user. At the ER modeling level, an entity actually refers to the entity set and not to a single entity occurrence. In other words, the word entity in the ERM corresponds to a table—not to a row—in the relational environment. The ERM refers to a table row as an entity instance or entity occurrence. • In both the Chen and Crow’s Foot notations, an entity is represented by a rectangle containing the entity’s name. The entity name, a noun, is usually written in all capital letters. • Attributes: • Attributes are characteristics of entities. For example, the STUDENT entity includes, among many others, the attributes STU_LNAME, STU_FNAME, and STU_INITIAL. In the original Chen notation, attributes are represented by ovals and are connected to the entity rectangle with a line. Each oval contains the name of the attribute it represents. • In the Crow’s Foot notation, the attributes are written in the attribute box below the entity rectangle. Because the Chen representation is rather space-consuming, software vendors have adopted the Crow’s Foot style attribute display. • Relationships: • A relationship is an association between entities. The entities that participate in a relationship are also known as participants, and each relationship is identified by a name that describes the relationship. The relationship name is an active or passive verb; for example, a STUDENT takes a CLASS, a PROFESSOR teaches a CLASS and an AIRCRAFT is flown by a CREW. • Relationships between entities always operate in both directions. That is, to define the relationship between the entities named CUSTOMER and INVOICE, you would specify that: 1. A CUSTOMER may generate many INVOICEs. 2. Each INVOICE is generated by one CUSTOMER. 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 4
  • 5. ERD Representations • There are three main notations to represent and ERD 1. The Chen notation favors conceptual modeling. 2. The Crow’s Foot notation favors a more implementation-oriented approach. 3. The UML notation can be used for both conceptual and implementation modeling. • Because of its implementation emphasis, the Crow’s Foot notation can represent only what could be implemented. • We will also be using a new Short Hand notation that is easy to understand and takes less place. 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 5
  • 6. Chen Notation Symbols 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 6
  • 7. Crow’s Foot Notation Symbols 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 7
  • 8. UML Notation Symbols Primary Keys are followed by [PK] Foreign Keys are followed by [FK] Relationships: Cardinality 1 for ‘One’. Cardinality * for ‘Many’. 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 8
  • 9. Advantages and Usage • Advantages: 1. ERD tells us that how many tables you need and what would be the relationship between them (you also have to do Normalization to know finally how many tables would be in your database but still first step is ERD). 2. ERD is simple and understandable representation of a database. It helps a lot to understand the whole database. • Usage: 1. An ERD leads to ERM, means when ever you need to build a database with tables, firstly, you need to create an ERD. 2. Crow’s foot notation is used most of all because its easy to understand in implementation point of view. 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 9
  • 10. Types of Entities • Existence Dependent An entity is said to be existence-dependent if it can exist in the database only when it is associated with another related entity occurrence. In implementation terms, an entity is existence-dependent if it has a mandatory foreign key—that is, a foreign key attribute that cannot be null. • Existence Independent. If an entity can exist apart from one or more related entities, it is said to be existence-independent (Sometimes designers refer to such an entity as a strong or regular entity). Here foreign key attribute can be null. 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 10
  • 11. Types of Attributes (1) • Required A required attribute is an attribute that must have a value; in other words, it cannot be left empty. • Optional An optional attribute is an attribute that does not require a value; therefore, it can be left empty. • Domains Attributes have a domain, a domain is the set of possible values for a given attribute. For example, the domain for the grade point average (GPA) attribute is written (0,4) because the lowest possible GPA value is 0 and the highest possible value is 4. The domain for the gender attribute consists of only two possibilities: M or F (or some other equivalent code). • Identifiers The ERM uses identifiers, that is, one or more attributes that uniquely identify each entity instance. In the relational model, such identifiers are mapped to primary keys (PKs) in tables. There are Simple(Primary Key) and Composite (Composite Key) identifiers. 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 11
  • 12. Types of Attributes (2) • Composite A composite attribute, not to be confused with a composite key, is an attribute that can be further subdivided to yield additional attributes. For example, the attribute ADDRESS can be subdivided into street, city, state, and zip code. • Simple A simple attribute is an attribute that cannot be subdivided. For example, age, sex, and marital status would be classified as simple attributes. • Single-Valued A single-valued attribute is an attribute that can have only a single value. For example, a person can have only one Social Security number, and a manufactured part can have only one serial number. Keep in mind that a single-valued attribute is not necessarily a simple attribute. For instance, a part’s serial number, such as SE-08-02-189935, is single-valued, but it is a composite attribute because it can be subdivided into the region in which the part was produced (SE), the plant within that region (08), the shift within the plant (02), and the part number (189935). • Multi-Valued Multivalued attributes are attributes that can have many values. For instance, a person may have several college degrees, and a household may have several different phones, each with its own number. Similarly, a car’s color may be subdivided into many colors (that is, colors for the roof, body, and trim). • Derived A derived attribute is an attribute whose value is calculated (derived) from other attributes. The derived attribute need not be physically stored within the database; instead, it can be derived by using an algorithm. For example, an employee’s age, EMP_AGE, may be found by computing the integer value of the difference between the current date and the EMP_DOB. 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 12
  • 13. How to Solve Multi-Valued attributes (1) • Although the conceptual model can handle M:N relationships and multivalued attributes, you should not implement them in the RDBMS. Because in the relational table, each column/row intersection represents a single data value. So if multivalued attributes exist, the designer must decide on one of two possible courses of action: 1. Within the original entity, create several new attributes, one for each of the original multivalued attribute’s components. For example, the CAR entity’s attribute CAR_COLOR can be split to create the new attributes CAR_TOPCOLOR, CAR_BODYCOLOR, and CAR_TRIMCOLOR, which are then assigned to the CAR entity. (Not good). 2. Create a new entity composed of the original multivalued attribute’s components. The new (independent) CAR_COLOR entity is then related to the original CAR entity in a 1:M relationship. Note that such a change allows the designer to define color for different sections of the car like top, body, interior etc. (Best solution). 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 13
  • 14. How to Solve Multi-Valued attributes (2) Entity CAR contains a multivalued attribute CAR_COLOR. Solution 1: (Not good) Solution to Multi-Valued attribute by adding new attributes to CAR entity. Solution 2: (Best) Solution to Multi-Valued attribute by adding new entity with 1:M relation to CAR entity. 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 14
  • 15. Relationships • Ways of Classifying Relationships Types A relationship type can be classified by the number of entity types involved, and by the degree of the relationship type. Following is a brief picture showing all types of relationships. 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 15
  • 16. Types of Relationships (1) • One-to-One • When both participants can have only one instance of each other. (less used but stable). • For Example, HUSBAND can have only one WIFE and WIFE can have only one HUSBAND. This is 1:1 relationship between HUSBAND and WIFE participants. • One-to-Many • When one participant can have multiple instances of other participants but other participant can have only one instance of first participants. (mostly used and stable). • For Example, CUSTOMER may generate many ORDERs but each ORDER is generated by one CUSTOMER. This is 1:M relation between CUSTOMER and ORDER. • Many-to-Many • When both participants can have multiple instances of each other. (not practice). • For Example, STUDENT can be enrolled in many SUBJECTs and one SUBJECT can be chosen by many STUDENTs. This is M:M relation between STUDENT and SUBJECT. 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 16
  • 17. Types of Relationships (2) • Weak relationship Also known as a non-identifying relationship, exists if the PK of the related entity does not contain a PK component of the parent entity. By default, relationships are established by having the PK of the parent entity appear as an FK on the related entity (implemented in right picture). • Strong relationship Also known as an identifying relationship, exists when the PK of the related entity contains a PK component of the parent entity (implemented in left picture). • Recursive relationship • A recursive relationship is one in which a relationship can exist between occurrences of the same entity set (Naturally, such a condition is found within a unary relationship). 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 17
  • 18. Relationships (1:1) – Implementation (1) • An example of a one-one relationship type is a person and his or her birth certificate. We assume that everyone has one and that a certificate registers the birth of one person only. • Where there is a one-one relationship type we have the option of merging the two entity types. The birth certificate attributes may be considered as attributes of the person and placed in the person entity type. The birth certificate entity type would then be removed. • There are two reasons for not merging them: 1. The majority of processing involving PERSON records might not involve any or many of the BIRTH_CERTIFICATE attributes. The BIRTH_CERTIFICATE attributes might only be subject to very specific processes which are rarely executed. 2. the BIRTH_CERTIFICATE entity type has relationship types to other entity types that the PERSON entity type does not have. The two entity types have different relationship types to other entity types. • Merging is not very harmful practically. so, its just a matter of choice which implementation you want. 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 18
  • 19. Relationships (1:1) – Implementation (2) • Following is implementations for 1:1 relationship. One table has PK and other table must have same PK as well as FK. Department Table has Department_ID as PK. And Manager Table must have Department_ID as PK as well as FK (You can change the name of column but it should have same data). 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 19
  • 20. Relationships (1:M) - Implementation • The common column is DEPARTMENT_ID (which is the primary key in the DEPARTMENT table) should be as a foreign key in the EMPLOYEE table. One individual DEPARTMENT_ID can relate to many rows in the EMPLOYEE table. Business Rule for this is: “one department can relate to one or many employees (or even no employees) and that an employee is associated with only one department (or, in some cases, no department).” 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 20
  • 21. Relationships (M:N) – Implementation (1) • Consider the EMPLOYEE and PROJECT tables. The business rule is as follows: One employee can be assigned to multiple projects, and one project can be supported by multiple employees. Therefore, it is necessary to create an M:M relationship to link these two tables. • In the relational database we don’t implement the M:N relation by just giving FKs to each other and the reason is we don’t want two sided links (circles). So, we create a new entity called Bridge Entity and its PK is a composite key made up with PKs of both tables. It may or may not have any other attributes but composite key is must. • After doing this, there becomes two 1:M relations. 1. One between Bridge and EMPLOYEE table (1:M). 2. One between Bridge and PROJECT table (1:M). 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 21
  • 22. Relationships (M:N) – Implementation (2) In this example we made Bridge Table under name EMPLOYEE_PROJECT containing PKs of both above tables. It has one more attribute for some extra information. Now, it becomes like this and we have three tables now. 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 22
  • 23. Removing Ternary and Hire order relations • It is advantageous (but not necessary) to remove ternary and higher order relationship types. One reason is that it might be considered more `natural' to think of entity types having attributes than relationship types having them. It is in fact always possible to remove these high-order relationship types and replace them with an entity type. A ternary relationship type is then replaced by an entity type and three binary relationship types linking it to the entity types which were originally linked by the ternary. A quaternary relationship type would be replaced by an entity type and four relationship types and so on. Ternary Relation Ternary Relation Solved into binary relations 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 23
  • 24. Connectivity and Cardinalities • Connectivity: The term connectivity is used to describe the relationship classification. Just to show the relation existence and type of relation between entities. • Cardinalities: Cardinality expresses the minimum and maximum number of entity occurrences associated with one occurrence of the related entity. In the ERD, cardinality is indicated by placing the appropriate numbers beside the entities, using the format (min , max). 1. Cardinality / mandatory: maximum cardinality. 2. Modality / optional: minimum cardinality or optionality. Picture says, one PROFESSOR can teach one (min 1) or more (max 4) CLASSes but each single (min 1) CLASS can be taught by one (max 1) PROFESSOR at time. 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 24
  • 25. Summary • Following are main steps to create an ERD 1. Decide what are the entitles in your database. 2. Decide attributes for each entity. 3. Describe relationships between entities. 1. If there is any M:N relation, solve it into 1:M relationships. • Note: ERD will not output a complete blue print to your database until you do its Normalization. But, ERD + Normalization will give you complete set of tables, attributes and relationships you need in your database. 19-Dec-14 Mudasir Qazi - mudasirqazi00@gmail.com 25