DBMS_Unit II_ER_EER
DBMS_Unit II_ER_EER
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.
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:
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
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
Unary relationship: Relationship which contains only one entity type is called unary
relationship .The degree of relationship is 1
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.
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:\
Ex:
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
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
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
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.
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.
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
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