ERModelling

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 125

Entity-Relationship Modeling

ER modeling:
A graphical approach for understanding and
designing database which is independent from
the actual database implementation.

The basic object that the ER model represents


is an entity.
Definitions from Navathe
Entity: An entity may be an object with a
physical existence or it may be an object with a
conceptual existence.

Example: Employee e1, company c1.

Attribute: The properties which describes the


entity.
Example: Name, address, age, phone.
Definitions from Navathe cont.2
Entity Type: An entity type defines a collection
of entities that have the same attributes.
Example: Company, Employee.

Key Attribute of an entity type: An entity type


usually has an attribute whose values are
distinct for each individual entity in the entity
set is called key attribute.
Example: vehicle registration number,
enrollment number etc.
Definitions from Navathe cont.3
Domains of attributes: Each simple attribute of
an entity type is associated with a value set
(domain of values), which specify the set of
values that may be assigned to that attribute for
each individual entity.
Example: Age attribute of employee has range
18 to 65 and domain is set of integer numbers
from 18 to 65.
Entity – is a thing in the real world with an independent
existence and about which we intend to collect data.
An entity may be an object with a physical existence (ex a
particular person, car, house, or employee)
It may be an object with a conceptual existence ( a
company, a job, or a university course)

Entity instance: a particular member of the entity type


e.g. a particular student
Attributes: Properties/characteristics that describe
entities
Ex – An EMPLOYEEE entity may be described by the
employee’s name, age, address, salary and job.
Relationships: Associations between entities
, Name of Degrees
Similarly Age can be calculated in terms of DOB and current date
Weak entity depends on strong entity to ensure the existence of weak entity. Like
strong entity, weak entity does not have any primary key, It has partial discriminator key.
Weak entity is represented by double rectangle. The relation between one strong and one
weak entity is represented by double diamond.

Weak entities are represented with double rectangular box in the ER Diagram and the
identifying relationships are represented with double diamond. Partial Key attributes are
represented with dotted lines.
E.g if Works-for is the relationship between the Employee entity and the department
entity, then Ram works for Comp.sc department, shyam works –for electrical
department ..etc are relationship instances of the relationship, works-for
Constraints on Relationship Type

Relationship type usually have certain constraints


that limit the possible combinations of entities
that may participate in the corresponding
relationship set.
For ex – if the company has a rule that each
employee must work for exactly one department,
then we would like to describe this constraint in
the schema.
Two main types of relationship constraint –
– Cardinality
– Participation
Cardinality – Specifies how many instances of an entity relate to
one instance of another entity

The minimum and maximum values of this connectivity is called the cardinality of the
relationship
Participation Constraint
Participation constraint specifies whether the existence of
an entity depends on its being related to another entity
via the relationship type. This specifies the minimum
number of relationship instances that each entity can
participate in.

This is of two types


 Total
 partial

Ex- If a company policy states that “every employee must


work for a department” then an employee entity exists
only if it participates in at least one WORK-FOR relationship
instance. Thus the participation of EMPLOYEE in WORKS-FOR
is called total participation.
All employees will not be head-of some department. So only few instances of
employee entity participate in the above relationship. But each department will be
headed by some employee. So department entity’s participation is total and
employee entity’s participation is partial in the above relationship.
Represented by ellipses connected to the entity type by straight
lines
Indicated by a double lined ellipse as shown in the figure.
Represented by an ellipse from which other ellipses emanate and represent the
component attributes. E.g Address.
•A relationship is represented as a diamond between two entity types.
•It has a label that explains the relationship. Usually the convention is to read the ER
diagram from top to bottom and from left to right.
•So, the relationship name is so chosen as to make sense when read from left to right.
•The relationship above is read as student enrolls-in course
•A unary relationship is represented as a diamond which connects one entity to itself as a
loop.
•The relationship above means, some instances of employee manage other instances of
Employee.
A relationship between two entity types.
A relationship connecting three entity types.
•All instances of the entity type Employee don’t participate in the relationship, Head-of.
•Every employee doesn’t head a department. So, employee entity type is said to partially
participate in the relationship.
•But, every department would be headed by some employee.
•So, all instances of the entity type Department participate in this relationship. So, we say that
it is total participation from the department side.
EMPLOYEE WORKS- DEPARTMENT
FOR

Total participation
These attributes best describe the relationship rather than any individual entity.
The identifying relationship is the one which relates the weak entity with the strong entity on
which it depends.
CASE STUDY 2: Suppose you are given the following
requirements for a simple database for the National Hockey
League (NHL):
•The NHL has many teams.
•Each team has a name, a city, a coach, a captain, and a set of
players.
•Each player belongs to only one team.
•Each player has a name, a position (such as left wing or goalie),
a skill level, and a set of injury records.
•A team captain is also a player.
•A game is played between two teams (referred to as host_team
and guest_team) and has a date (such as May 11th, 1999) and a
score (such as 4 to 2).
• Construct a clean and concise ER diagram for the NHL
database.
CASE STUDY 3: Construct an E-R diagram for a
car-insurance company whose customers own
one or more cars each. Each car has associated
with it zero to any number of recorded
accidents.
Q. Entity Relationship Diagram ?
Q. Entity Relationship Diagram ?
Ans. It is a graphical representation of Entity
Relationship Model.
Q. Entity Relationship Diagram ?
Ans. It is a graphical representation of Entity
Relationship Model.

Q1. Entity Relationship Model ?


Q. Entity Relationship Diagram ?
Ans. It is a graphical representation of Entity
Relationship Model.

Q1. Entity Relationship Model ?


Ans. A database which modeled as:
– a collection of entities,
– relationship among entities.

Q2. What is an Entity?


Q. Entity Relationship Diagram ?
Ans. It is a graphical representation of Entity Relationship
Model.

Q1. Entity Relationship Model ?


Ans. A database which modeled as:
– a collection of entities,
– relationship among entities.

Q2. What is an Entity?


Ans. An entity is an object that exists and is
distinguishable from other objects.
– Example: specific person, company, event, plant
Q. Entity Relationship Diagram ?
Q3. How we represent an Entity in ER Model?
Q. Entity Relationship Diagram ?
Q3. How we represent an Entity in ER Model?
Ans. An entity is represented by a set of attributes. Eg. Entity person have the
attributes like F_Name, L_Name, Address etc.
Q. Entity Relationship Diagram ?
Q3. How we represent an Entity in ER Model?
Ans. An entity is represented by a set of attributes. Eg. Entity person have the
attributes like F_Name, L_Name, Address etc.
Q4. What you understand with attributes?
Q. Entity Relationship Diagram ?
Q3. How we represent an Entity in ER Model?
Ans. An entity is represented by a set of attributes. Eg. Entity person have the
attributes like F_Name, L_Name, Address etc.
Q4. What you understand with attributes?
Ans. Attributes are descriptive properties possessed by all members of an entity
set.
Q. Entity Relationship Diagram ?
Q3. How we represent an Entity in ER Model?
Ans. An entity is represented by a set of attributes. Eg. Entity person have the
attributes like F_Name, L_Name, Address etc.
Q4. What you understand with attributes?
Ans. Attributes are descriptive properties possessed by all members of an entity
set.
Q5. Types of Attributes?
Q. Entity Relationship Diagram ?
Q3. How we represent an Entity in ER Model?
Ans. An entity is represented by a set of attributes. Eg. Entity person have the
attributes like F_Name, L_Name, Address etc.
Q4. What you understand with attributes?
Ans. Attributes are descriptive properties possessed by all members of an entity
set.
Q5. Types of Attributes?
Ans. 1. Simple Attribute
2. Composite Attribute
3. Single Valued Attribute
4. Multivalued Attribute
5. Derived Attribute
Q. Entity Relationship Diagram
Q6. Example of Composite Attribute ?
Q. Entity Relationship Diagram
Q6. Example of Composite Attribute ?
Ans.
Q. Entity Relationship Diagram ?
Q7. Examples of Multi Valued and Derived attributes ?
Q. Entity Relationship Diagram ?
Q7. Examples of Multi Valued and Derived attributes ?
Ans.
•Multi Valued attribute – An attribute can have more than one values. Eg. Phone
Number
Q. Entity Relationship Diagram ?
Q7. Examples of Multi Valued and Derived attributes ?
Ans.
•Multi Valued attribute – An attribute can have more than one values. Eg. Phone
Number
•Derived attribute – An attribute can be computed from other attributes. Eg. Age
Q. Entity Relationship Diagram ?
Ans. It is a graphical representation of Entity
Relationship Model.

Q1. Entity Relationship Model ?


Ans. A database which modeled as:
– a collection of entities,
– relationship among entities.
Q. Entity Relationship Diagram ?
Ans. It is a graphical representation of Entity
Relationship Model.

Q1. Entity Relationship Model ?


Ans. A database which modeled as:
– a collection of entities,
– relationship among entities.
Q8. What do you mean by “relationship among entities” ?
Q. Entity Relationship Diagram ?
Ans. It is a graphical representation of Entity
Relationship Model.

Q1. Entity Relationship Model ?


Ans. A database which modeled as:
– a collection of entities,
– relationship among entities.
Q8. What do you mean by “relationship among entities” ?
Ans. A relationship is an association among several entities
Example: student entity advisor instructor entity
“advisor” is the relationship name among two entities “student” and “instructor”.
Q. Entity Relationship Diagram?
Q9. Can we associate attributes with relationship sets?
Q. Entity Relationship Diagram?
Q9. Can we associate attributes with relationship sets?
Ans. Yes we can associate. Eg.
Q. Entity Relationship Diagram ?
Q10. What is the degree of a relationship set?
Q. Entity Relationship Diagram ?

Q10. What is the degree of a relationship set?


Ans. Degree = No. of entities participate in a relation

In this example degree of the relationship set “ advisor” is 2.


Q. Entity Relationship Diagram ?
Q11. What is the minimum degree of a relationship set?
a.1
b.2
c.0
d.3
Q. Entity Relationship Diagram ?
Q11. What is the minimum degree of a relationship set?
a.1
b.2
c.0
d.3
Q. Entity Relationship Diagram?
Q12. What are the possible mapping cardinalities for a relationship set?
Q. Entity Relationship Diagram?
Q12. What are the possible mapping cardinalities for a relationship set?
Ans.
As per the rules:
Derived attributes are ignored
Composite attributes are represented by components
Multi-valued attributes are represented by a separate table
Here dependant is a weak entity. Dependant doesn’t mean anything to the problem without
the information on for which employee the person is a dependant.
Extended E-R Features: Specialization

• Top-down design process; we designate subgroupings


within an entity set that are distinctive from other
entities in the set.
• These subgroupings become lower-level entity sets that
have attributes or participate in relationships that do not
apply to the higher-level entity set.
• Depicted by a triangle component labeled ISA (E.g.
customer “is a” person).
• Attribute inheritance – a lower-level entity set inherits
all the attributes and relationship participation of the
higher-level entity set to which it is linked.
Extended ER Features: Generalization

• A bottom-up design process – combine a


number of entity sets that share the same
features into a higher-level entity set.
• Specialization and generalization are simple
inversions of each other; they are represented
in an E-R diagram in the same way.
• The terms specialization and generalization
are used interchangeably.
Design Constraints on a Specialization/Generalization
• Constraint on which entities can be members of a given lower-
level entity set.
– condition-defined
• Example: all customers over 65 years are members of
senior-citizen entity set; senior-citizen ISA person.
– user-defined
• Constraint on whether or not entities may belong to more than
one lower-level entity set within a single generalization.
– Disjoint
• an entity can belong to only one lower-level entity set
• Noted in E-R diagram by writing disjoint next to the ISA
triangle
– Overlapping
• an entity can belong to more than one lower-level entity
set
Design Constraints on a Specialization/Generalization
(Cont.)
• Completeness constraint -- specifies whether
or not an entity in the higher-level entity set
must belong to at least one of the lower-level
entity sets within a generalization.
– total : an entity must belong to one of the lower-
level entity sets
– partial: an entity need not belong to one of the
lower-level entity sets
Aggregation
• Consider the ternary relationship works_on, which we saw earlier
• Suppose we want to record managers for tasks performed by an
employee at a branch
Aggregation (Cont.)
• Relationship sets works_on and manages represent overlapping
information
– Every manages relationship corresponds to a works_on
relationship
– However, some works_on relationships may not correspond to
any manages relationships
• So we can’t discard the works_on relationship
• Eliminate this redundancy via aggregation
– Treat relationship as an abstract entity
– Allows relationships between relationships
– Abstraction of relationship into new entity
• Without introducing redundancy, the following diagram represents:
– An employee works on a particular job at a particular branch
– An employee, branch, job combination may have an associated
manager
E-R Diagram With Aggregation
Deriving Logical Schema for Online Retail Application
Thank You

You might also like