You are on page 1of 23

Entity Relational Model

ER Model is a high level conceptual Design


It uses concepts such as entities, relations and
attributes.
An ER diagram (ERD) is a graphical
representation of the ER Model.
Entity

• An entity is an object with a physical existence


• E.g. A person, A cat, A house
• Or it may be an object with conceptual
existence such as a job, a university
Attributes
• A Property used to describe an entity
• E.g. an Employee entity can have emp_no,
name, address, TP_Number Attributes
• A particular entity will have a values for each
of its attributes
• The attribute values that describes each entity
becomes a major part of the data stored in the
database
Types of Attributes
• Simple (atomic) attributes – An attribute that is not
devisable (Broken down into smaller components)
• Eg:- Emp_No
• Composite attributes – An attribute which can
divide into smaller subparts which represent more
basic attributes with independent meaning
• E.g. An Address attribute can divide in to No, Street,
City, Postal Code
• The value of a composite attribute is the
concatenation of the values of its constituent simple
attributes
Types of Attributes
• Single valued Attribute – Most attributes have a
single value for a part entity and such attribute is
called single value attribute
• E.g. Age
• Multivalued Attribute - In some cases an attribute
can have a set of values for each entity
• E.g. Colour attribute of Car entity or Qualifications
attribute of Employee attribute
• A multivalued attribute may have lower and upper
bound to constrain the number of values it can have
• E.g. Colour attribute of Car may have a constrain
between one and three based on an assumption
Types of Attributes
• Stored Attribute – An attribute value which is stored
independently by not deriving from other attributes
• E.g. Date_of_Birth
• Derived Attribute – An attribute who's values are
calculated from another stored attribute
• E.g. Age which is derived from Date_of_Birth
• Some attribute may derived from related entities
• E.g. No_of_emplyees in a DEPARTMENT is
calculated using the total of EMPLOYEES entity
Entity Type
• A database usually contains groups of entities those
are similar
• E.g. A company may have hundreds of employees
and may want to store similar data.
• These employee entity share the same attribute but
may have different values
• Collection of entities which have the same attribute is
called an Entity Type
• Each Entity type is described by its name and its
attributes
• The collection of all entities of a particular entity
type in the database at any point of time is called
an entity Set
• Some times the name of the Entity type may
also used to entity set
• E.g. Employee
Key Attribute
• An entity type usually has an attribute or
combination of attributes whose values are
distinct from each individual entity
• Such attribute is called a key attribute and its
values can be used to identify each entity
uniquely.
• If the set of attribute posses this property then
a proper way to represent this in ERD is to
derive a composite attribute and designate it
with a key attribute
Domain of Attribute
• Also known as Value Set of an attribute
• The set of values that may be assigned to each
attribute of an individual entity of an entity
type
• E.g. The age of an attribute of an Employee
may have an integer between 18 to 60
• Value sets are defined using data type such as
integer, float in the programming language
Strong Entity vs. Weak Entity
• An entity type which independently exists are called
Strong entity and it has its own Key attribute
• A week entity is dependent of the strong entity and it
cannot exists its own
• It does not have its own Key Values
• Ex :- Dependent entity is identified by the dependent
first name, birth date and specific employee that
dependent is related to. So dependent is a weak
entity.
Relationship
• A relationship is an association among several
entities
• E.g. James works in IT Department
• A relationship set is a set of relationship of
same type
• A relationship instance in an ERD schema
represent an association between the named
entities in the real world enterprise that is
being modeled
Symbols
Relationship
• Number of entity types participate in a relationship is
called the degree.
• A relationship where the same entity participate in
more than once is called Recursive or Unary
relationship
• E.g. Employee is supervised by an employee
• In binary relationship two entities are connected
• E.g. EMPLOYEE works for DEPARTMENT
• This involves three entitles and is used when binary
relationship is inadequate
• Supplier Supplies Parts for Projects
Relationship types usually have certain constraints that
limit the possible combinations of certain entities that
may participate in the corresponding relationship set.

Ex : If a Company has the rule that each employee


must work for exactly one department, then we would
like to describe this constraint in the schema.

We can distinguish two main types of relationship


constraints,
1. Cardinality Ratio and Participation.
Cardinality Ratio and Participation
• A relationship may have some constraint that
may limit the possible combination of entities
that may participate in relationship instances
• The Cardinality Ratio specifies the number of
relationship that an entity can participate
• One to one (1:1)
• One to Many (1:M)
• Many to Many (M:N)
One to one (1:1)

• An entity in A is associated with at most one


entity in B and an entity in B is associated with
at most one entity in A
• E.g. Department entity to employee entity who
manages that department
One to Many (1:M)

• An entity in A is associated with any number


of (zero or more) entity in B and an entity in
B is associated with at most one entity in A
• E.g. one Employee can work in one
department but many employees can work in
one department
Many to Many (M:N)

• An entity in A is associated with any number


of (zero or more) entity in B and an entity in
B is associated with any number of (zero or
more) A
• E.g. if one lecturer can deliver lectures in
many courses and many lecturers are doing a
course
Participation Constraints

• The Participation of an entity set E in a


relationship set R is sad to be Total if every
entity in E participate at least one relationship
• Employee works on Department
• Total participation is called Existence
Dependency.
• In ER diagrams, total participation is displayed
as a double line.
• If only some entities in E participates in
relationship in R, the participations of set
E in relationship is said to be partial
• Employee manages Department
• Partial participation is displayed as a
single line.
Notation for ER Diagram
Symbol Meaning
Entity

Weak Entity

Relationship

Identifying Relationship

Attribute

Key Attribute
Notations….
Symbol Meaning

Multivalued Attribute

Composite Attribute

Derived Attribute

Total participation of E2
E1 R E2 in R
1 N Cardinality ratio 1:N for
E1 R E2 E1:E2 in R

You might also like