0% found this document useful (0 votes)
10 views

DBMS_Unit II_ER_EER

The document provides an overview of the Entity-Relationship (ER) model, which is a conceptual framework for designing database applications using entities, relationships, and attributes. It discusses various components of ER diagrams, including entity types, weak and strong entities, attribute classifications, and relationship types, as well as the process of mapping ER diagrams to relational schemas. Additionally, it introduces the Enhanced Entity-Relationship (EER) model, which extends the ER model by incorporating concepts such as generalization and specialization.

Uploaded by

anil kasula
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

DBMS_Unit II_ER_EER

The document provides an overview of the Entity-Relationship (ER) model, which is a conceptual framework for designing database applications using entities, relationships, and attributes. It discusses various components of ER diagrams, including entity types, weak and strong entities, attribute classifications, and relationship types, as well as the process of mapping ER diagrams to relational schemas. Additionally, it introduces the Enhanced Entity-Relationship (EER) model, which extends the ER model by incorporating concepts such as generalization and specialization.

Uploaded by

anil kasula
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Entity-Relationship Model-UNIT 2

ER Model: Entity relationship model is conceptual data model used for the conceptual
design of database applications. The ER model describes data as entities relationships and
attributes.

The building blocks of an entity relationship diagram:

There are three building blocks used in an ERD: entities, relationships and attributes.

Entity: an entity is an object which is the thing in the real world with an independent
existence An entity may be an object with physical existence (Person, car, book …)
or it may be an object with conceptual existence (job, course …)

Notation: Rectangle

Ex:
Attribute: The properties which describe an entity is called attribute
Example: An Entity student will have attributes snumber, name address mobile number
Notation: ellipse or oval

Ex:

Relationship: Relationship represents Association among entities

Relationships are classified in terms of degree, connectivity, cardinality and existence.

Notation: diamond symbol

Entity type: An entity type defines collection of entities that have same attributes.
An entity type describes the schema intension for a set of entities that share the same structure
Entity set: the collection of all entities of a particular entity type in the database at any point of
time is called entity set which is referred by the same name as entity type

ER Notations (or) ER symbols


Classification of Entity sets:

1. STRONG ENTITY TYPE


2. WEAK ENTITY TYPE

STRONG ENTITY TYPE: The Entity types which have key attributes are strong entity type example In
employee dependent relationship employee is the strong entity type.

WEAK ENTITY TYPE: Weak entity type do not have key attributes of their own. Weak entity type will
have a Partial Key.
Example: in an employee dependent relationship employee is the strong entity type and dependent is
weak entity type a weak entity type will have a partial key the uniquely identify weak entities that that
are related to the owner entity

Fig: A weak Entity Type DEPENDENT is in Identifying Relationship with Strong Entity Type
EMPLOYE
Classification of Attributes:

Single valued attributes: Attributes with the single value for a particular entity are called
Single valued attributes.Example: Roll number of student, Social security number of employee

Multivalued attribute: Multivalued attribute may have lower and upper bounds to constrain
the number of values allowed for an entity. Its notation is double lined ellipse
Example: Location of departments, hobbies of a person, college degrees of a person

Simple attributes: Attributes which are not divisible into sub parts are simple attributes. Ex: salary,
stu_id

Composite attribute: Composite attribute can be divided into smaller parts which represent
more basic attributes with independent meaning example name
Example: name, address . . .

Key attributes: Attributes whose value can be used to identify each entity uniquely is called
key attribute Example: Roll number of students, Social security number of employees.

Stored attribute: Attribute from which we can derive some other attribute is called store
attribute Example: date of birth is stored attribute from which we can derive age

Derived attribute: An attribute that is derived from a related attribute is called derived
attribute.it is denoted by dotted ellipse
Example: Age is derived from date of birth

Relationship Degree:- The number of entities in a relationship is called degree of relationship


type .There are three types of relationships
1. Unary relationship
2. Binary relationship
3. Ternary relationship

Unary relationship: Relationship which contains only one entity type is called unary
relationship .The degree of relationship is 1

Fig: Unary relationship


Binary relationship: Relationship which contains two entity sets is called binary relationship.
The degree of binary relationship is 2

Fig: Binary relationship


Ternary relationship: This relationship contains three entity types degree of relationship is
three Example bank has many numbers of branches and customers can have any number of
accounts in branches

Fig: Ternary relationship

Relationship Type: A Relationship Type is set of associations among Entities from Entity Types.
A relationship type R among n entity types E1, E2, ..., En defines a set of associations
(relationship set) among entities from these entity types.
The WORKS_FOR Relationship set associates entity sets EMPLOYEE and Department.
EMPLOYEE e1,e3 works for DEPARTMENT d2 and e1,e5 works for DEPARTMENT d1
and e4 works for DEPARTMENT d2.

The ER-Diagram to represent Relationship:

Fig: WORKS_FOR Relationship Associates Entity types EMPLOYEE and DEPARTMENT

Classification of Relationship: The cardinality ratio for a binary relationship specifies the
maximum number of relationship instances that an entity can participate in. there are four types
of mapping constraints they are

1.one to one
2. one to many
3. many to one
4. .many to many

1. One To One Relationship: Let us assume that A and B are two entity sets is associated with
at most one entity in B and an entity in B associated with at most one entity in A is called one to
one relationship
Ex:\

2. One To Many Relationship:


An entity in A is associated with any number of entities in B entity in B is associated with at
most one entity in A is called one to many relationship
Ex:
3.Many To One Relationship: An entity in A is associated with at most one entity in B and an
entity in B is associated with any number of entities in a is called many to one

Ex:

4.Many To Many Relationship: An entity in A is associated with any number of entities in B


and vice versa is many to many relationship
Mapping ER diagram to Relations:
ER Diagram for the COMPANY Schema:
STEP 1: MAP REGULAR ENTITY TYPES:

For each regular entity type, create a relation schema R that includes all the single-valued
attributes of E
• For each composite attribute, add its simple component attributes
• Example renames some attributes (e.g., Dname), but not needed
• Pick one of the keys as “primary key” and declare the rest to be unique
• Called entity relations
• Each tuple represents an entity instance

STEP 2 : MAP WEAK ENTITY TYPES

For each weak entity type, create a relation schema R and include
all single-valued attributes of the entity type as attributes of R
• Include primary key attribute of “owner” as foreign key attribute of R
• Primary key of R is primary key of owner together with discriminant attribute from R

STEP 3: MAP BINARY 1:1 RELATIONSHIP TYPES

For each binary 1:1 relationship type R, identify relation schemas that
correspond to entity types participating in R
Apply one of three possible approaches:
• Foreign key approach
1. Add primary key of one participating relation as foreign key attribute of the other,
which will also represent R
2. If only one side is total, choose it to represent R
3. Declare foreign key attribute as unique
• Merged relationship approach
1. Combine the two relation schemas into one, which will also
represent R
2. Make one of the primary keys “unique” instead
3. Add single-valued attributes of relationship type as attributes of R
STEP 4: MAP BINARY 1: N RELATIONSHIP TYPES

• Identify relation schema S that represents participating entity type


at N-side of 1:N relationship type
• Include primary key of other entity type (1-side) as foreign key in S

STEP 5: MAP BINARY M : N RELATIONSHIP TYPES

For each binary M:N relationship type, create a new relation S


• Include primary key of participating entity types as foreign key attributes in S
• Make all these attributes primary key of S
• Include any simple attributes of relationship type in S

STEP 6: MAP MULTIVALUED ATTRIBUTES

For each multivalued attribute


• Create new relation R with attribute to hold multivalued attribute
values
• If multivalued attribute is composite, include its simple components
• Add attribute(s) for primary key of relation schema for entity or relationship type to be foreign
key for R
• Primary key of R is the combination of all its attributes
STEP 7: MAP N-ary Relationship type to Relations

For each N-ary relationship type, create a new relation S


• Include primary key of participating entity types as foreign key attributes in S
• Make all these attributes primary key of S
• Include any simple attributes of relationship type in S

Algorithm for ER-to-relational mapping


Enhanced Entity-Relationship Model (EER model):-

Enhanced Entity relationship model is extension of ER model with the new modelling
techniques such as
1. super class
2. subclass
3. specialization
4. generalization

SUPER CLASS: Super class is a generic entity type which contains one or more subtypes

SUB CLASS: A SUB c l a s s is derived from SUPER TYPE which consists all the
attributes of SUPER CLASS as well as attributes of its own.
A super class is connected by the line to the circle again align to each subclass which contains
subset symbol the attributes common for common for all entity types is associated with super
class.

FIG: SUPER CLASS AND SUBCLASS NOTATION

Generalization and Specialization:

SPECIALIZATION: Specialization is the process defining a set of subclasses of an entity


type, this entity type is called super class of specialization. The set of subclasses that form
specialization is defined on the basis of some distinguishing characteristics of the entities in the
super class. Specialization is a top down approach

Example: the set of subclass secretary engineer technician is a specialization of super class
employees
The above example is the specialization of EMPLOYEE Super type based on Job type.
The sub classes are SECRETARY, TECHNICIAN and ENGINEER.
The attributes name, ssn, birth date, Address , job type of entity type EMPLOYEE are common
for SECRATERY.

DISJOINTNESS: which specifies that the subclasses of the specialization must be disjoint.
This means that an entity can be a member of at most one of the subclasses of the specialization.
Notation : d

OVERLAPPING: the same (real-world) entity may be a member of more than one subclass
of the specialization. This case, which is the default, is displayed by placing an o in the circle.

TOTAL SPECIALIZATION :A total specialization constraint specifies that every entity in


the superclass must be a member of at least one subclass in the specialization.

For example, if every EMPLOYEE must be either an HOURLY_EMPLOYEE or a


SALARIED_EMPLOYEE, then the specialization {HOURLY_EMPLOYEE,
SALARIED_EMPLOYEE} in Figure 8.1 is a total specialization of EMPLOYEE.
PARTIAL SPECIALIZATION: A single line is used to display a partial specialization,
which allows an entity not to belong to any of the subclasses.

For example, if some EMPLOYEE entities do not belong to any of the subclasses
{SECRETARY, ENGINEER, TECHNICIAN}

GENERALIZATION: It is the process of creating the general entity type from a set of
specialized entity types. Generalization is a bottom up approach.
Ex: let us assume that there are vehicles car and truck with attributes with id, price, no of
passengers, license . We create a generic class VEHICLE with all the common attributes id,
name, license.

We can observe that the generalization process can be viewed as being functionally the inverse
of the specialization process.
IS A relationship and attribute inheritance

1. Generalization
• Generalization is the process of generalizing the entities which contain the properties of
all the generalized entities.
• It is a bottom up approach, in which two lower level entities combine to form a higher-
level entity.
• Generalization is the reverse process of Specialization.
• It defines a general entity type from a set of specialized entity types.
• It minimizes the difference between the entities by identifying the common features.
For example:

In the above example, Tiger, Lion, Elephant can all be generalized as Animals.
It is just like saying "A is a B type of thing". For example, Apple is a Fruit, Car is a Vehicle etc.
Inheritance is uni-directional. For example, House is a Building. But Building is not a House.

2. Specialization
• Specialization is a process that defines a group entity which is divided into sub groups
based on their characteristic.
• It is a top down approach, in which one higher entity can be broken down into two lower
level entity.
• It maximizes the difference between the members of an entity by identifying the unique
characteristic or attributes of each member.
• It defines one or more sub class for the super class and also forms the
superclass/subclass relationship.
For example
In the above example, Employee can be specialized as Developer or Tester, based on what role
they play in an Organization.

Inheritance
Inheritance is an important feature of Generalization and Specialization. It allows lower-level
entities to inherit the attributes of higher-level entities.

For example, the attributes of a Person class such as name, age, and gender can be inherited by
lower-level entities such as Student or Teacher.
Multiple inheritance in DBMS
In multiple inheritance, lower level entity type may inherit properties and methods from
different higher-level entity types.
Constraints on specialization and generalization

There are three constraints that may apply to a specialization/generalization:


1. Membership constraints
2. Disjoint constraints
3. Completeness constraints.
• Membership constraints
Condition defined: Membership of a specialization/generalization relationship can be defined
as a condition in the requirements e.g. tanker is a ship where cargo = ‘oil’
User defined: Sometimes the designer can define the superclass-subclass relationship. This can
be done to simplify the design model or represent a complex relationship that exists between
entities.
• Disjoint constraints
Disjoint: The disjoint constraint only applies when a superclass has more than one subclass. If
the subclasses are disjoint, then an entity occurrence can be a member of only one of the
subclasses, e.g. postgrads or undergrads you cannot be both. To represent a disjoint
superclass/subclass relationship, Or is used.

Figure 7.13
Overlapping: This applies when an entity occurrence may be a member of more than one
subclass, e.g. student and staff some people are both. And is used to represent the overlapping
specialization/generalization relationship in the ER diagram.
Figure 7.14
• Completeness constraints
Total: Each superclass (higher-level entity) must belong to subclasses (lower-level entity sets),
e.g. a student must be postgrad or undergrad. To represent completeness in the
specialization/generalization relationship, the keyword Mandatory is used.

Partial: Some super classes may not belong to subclasses (lower-level entity sets), e.g. some
people at UCT are neither student nor staff. The keyword Optional is used to represent a partial
specialization/generalization relationship.

We can show both disjoint and completeness constraints in the ER diagram. Following our
examples, we can combine disjoint and completeness constraints.
Some members of a university are both students and staff. Not all members of the university are
staff and students.

A student in the university must be either an undergraduate or postgraduate, but not both.

Advantages of ER modelling
1.Exceptional conceptual simplicity
2. Visual representation
3. Effective communication tool
4. Integrated with the relational database model

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy